Error executing template "Designs/Rapido/Paragraph/ParagraphContainer.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_31e44a387ac14fedbe04d6357963eb8d.Execute() in f:\Domains\Sites\asibrake.com\Files\Templates\Designs\Rapido\Paragraph\ParagraphContainer.cshtml:line 2389
   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.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   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 1883 1884 1885 @* Include the basic, re-used, paragraph initializer *@ 1886 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 1887 @using Dynamicweb.Frontend 1888 @using Dynamicweb.Rapido.Blocks.Components.General 1889 @using Dynamicweb.Rapido.Blocks.Components 1890 1891 @functions { 1892 public class ContentParagraph 1893 { 1894 public string Title { get; set; } 1895 public Image Image { get; set; } 1896 public string Text { get; set; } 1897 public string Link { get; set; } 1898 public bool SetImageAsBackground { get; set; } 1899 public bool HideOuterPadding { get; set; } 1900 public string InnerPaddingCss { get; set; } 1901 public string CardCss { get; set; } 1902 public string ButtonWrapperCss { get; set; } 1903 public string Layout { get; set; } 1904 public string Module { get; set; } 1905 public Link ButtonPrimary { get; set; } 1906 public Link ButtonSecondary { get; set; } 1907 } 1908 } 1909 1910 @helper RenderParagraph(ItemViewModel item, bool renderModule = true) 1911 { 1912 if (item != null) { 1913 string layout = item.GetList("ContentPositions").SelectedValue; 1914 1915 string paragraphClasses = ""; 1916 string paragraphWidth = !String.IsNullOrEmpty(item.GetString("Width")) ? item.GetList("Width").SelectedValue : "12"; 1917 paragraphClasses += " grid__col-lg-" + paragraphWidth + " grid__col-md-" + paragraphWidth + " grid__col-sm-" + paragraphWidth; 1918 if (item.GetList("WidthMobile").SelectedValue == "hide") 1919 { 1920 paragraphClasses += " u-hidden-xs"; 1921 } 1922 else 1923 { 1924 paragraphClasses += " grid__col-xs-" + item.GetList("WidthMobile").SelectedValue; 1925 } 1926 paragraphClasses += item.GetBoolean("HidePadding") ? " paragraph-container--no-padding" : ""; 1927 paragraphClasses += layout == "middle-center" || layout == "middle-left" ? " u-middle-horizontal grid--justify-center grid--align-self-center" : ""; 1928 1929 //Alternative Design Layout 1930 var designLayout = Model.Item.GetItem("CustomSettings") != null ? Model.Item.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.Item.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 1931 paragraphClasses += !String.IsNullOrEmpty(designLayout) ? designLayout : ""; 1932 1933 string title = item.GetBoolean("ShowTitle") ? item.GetString("Title") : ""; 1934 string cardClass = item.GetBoolean("ShowAsCard") ? "paragraph-card" : ""; 1935 string buttonSpacing = ""; 1936 string buttonAlignment = layout == "all-centered" || layout == "middle-center" ? "grid--justify-center" : ""; 1937 1938 string image = item.GetFile("Image") != null ? item.GetFile("Image").ToString() + "&" + item.GetFile("Image").GetFocalPointParameters() : ""; 1939 int cropMode = !String.IsNullOrEmpty(Converter.ToString(item.GetList("ImageCrop"))) ? Convert.ToInt32(item.GetList("ImageCrop").SelectedValue) : 0; 1940 ImageStyle imageStyle = item.GetList("ImageStyle").SelectedValue == "ball" ? ImageStyle.Ball : ImageStyle.None; 1941 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; 1942 if (primaryButtonLayout == ButtonLayout.Link) 1943 { 1944 primaryButtonLayout = ButtonLayout.LinkClean; 1945 } 1946 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; 1947 if (secondaryButtonLayout == ButtonLayout.Link) 1948 { 1949 secondaryButtonLayout = ButtonLayout.LinkClean; 1950 } 1951 ImageFilter primaryImageFilter = !string.IsNullOrEmpty(item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 1952 ImageFilter secondaryImageFilter = !string.IsNullOrEmpty(item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 1953 string imageFilterColorCode = item.GetString("ColorForTheFilter").StartsWith("#") && primaryImageFilter == ImageFilter.Colorize ? GenerateRgba(item.GetString("ColorForTheFilter"), 0.3) : ""; 1954 bool setImageAsBackground = item.GetList("ImageStyle").SelectedValue.ToLower() == "background" ? true : false; 1955 1956 Image paragraphImage = null; 1957 if (!String.IsNullOrEmpty(image)) 1958 { 1959 paragraphImage = new Image 1960 { 1961 Path = image, 1962 Link = item.GetString("Link"), 1963 FilterPrimary = primaryImageFilter, 1964 FilterSecondary = secondaryImageFilter, 1965 FilterColor = imageFilterColorCode, 1966 Style = imageStyle, 1967 ImageDefault = new ImageSettings 1968 { 1969 Crop = cropMode, 1970 Height = 845, 1971 Width = 1920 1972 }, 1973 ImageMedium = new ImageSettings 1974 { 1975 Crop = cropMode, 1976 Height = 450, 1977 Width = 1024 1978 }, 1979 ImageSmall = new ImageSettings 1980 { 1981 Crop = cropMode, 1982 Height = 544, 1983 Width = 640 1984 } 1985 }; 1986 } 1987 1988 if (paragraphWidth != "auto" && paragraphImage != null) { 1989 if (Convert.ToInt32(paragraphWidth) < 7) 1990 { 1991 paragraphImage.ImageDefault = new ImageSettings 1992 { 1993 Crop = cropMode, 1994 Height = 544, 1995 Width = 640 1996 }; 1997 } 1998 } 1999 2000 ContentParagraph paragraph = new ContentParagraph 2001 { 2002 Title = title, 2003 Text = item.GetString("Text"), 2004 Image = paragraphImage, 2005 Link = item.GetString("Link"), 2006 Module = !String.IsNullOrEmpty(Model.GetModuleOutput()) && renderModule ? Model.GetModuleOutput() : "", 2007 InnerPaddingCss = item.GetList("InnerPadding") != null ? "paragraph-container__body--padding-" + item.GetList("InnerPadding").SelectedValue : "", 2008 CardCss = cardClass, 2009 HideOuterPadding = item.GetBoolean("HidePadding"), 2010 SetImageAsBackground = item.GetList("ImageStyle").SelectedValue.ToLower() == "background" ? true : false, 2011 ButtonWrapperCss = buttonSpacing + buttonAlignment, 2012 Layout = layout 2013 }; 2014 2015 if (!String.IsNullOrEmpty(item.GetString("Link"))) 2016 { 2017 paragraph.ButtonPrimary = new Link 2018 { 2019 Href = item.GetString("Link"), 2020 Title = item.GetString("LinkText"), 2021 ButtonLayout = primaryButtonLayout, 2022 CssClass = "u-no-margin" 2023 }; 2024 2025 if (!String.IsNullOrEmpty(item.GetString("SecondaryLink"))) { 2026 paragraph.ButtonPrimary.CssClass = ""; 2027 } 2028 } 2029 2030 if (!String.IsNullOrEmpty(item.GetString("SecondaryLink"))) 2031 { 2032 if (!String.IsNullOrEmpty(item.GetString("Link"))) 2033 { 2034 paragraph.ButtonPrimary.CssClass += " u-margin-right--lg"; 2035 } 2036 2037 paragraph.ButtonSecondary = new Link 2038 { 2039 Href = item.GetString("SecondaryLink"), 2040 Title = item.GetString("SecondaryLinkText"), 2041 ButtonLayout = secondaryButtonLayout 2042 }; 2043 } 2044 2045 <div class="paragraph-container @paragraphClasses dw-mod"> 2046 @if (setImageAsBackground == true && paragraphImage != null) 2047 { 2048 paragraphImage.CssClass = "background-image__cover"; 2049 2050 <div class="background-image dw-mod"> 2051 <div class="background-image__wrapper dw-mod"> 2052 @Render(paragraphImage) 2053 </div> 2054 </div> 2055 } 2056 @{ 2057 switch (layout) 2058 { 2059 case "title-top": 2060 @RenderLayoutTitleTop(paragraph) 2061 break; 2062 case "image-left": 2063 @RenderLayoutImageLeft(paragraph) 2064 break; 2065 case "image-right": 2066 @RenderLayoutImageRight(paragraph) 2067 break; 2068 case "image-centered": 2069 @RenderLayoutImageCentered(paragraph) 2070 break; 2071 case "all-centered": 2072 @RenderLayoutAllCentered(paragraph) 2073 break; 2074 case "middle-center": 2075 case "middle-left": 2076 @RenderLayoutMiddle(paragraph) 2077 break; 2078 default: 2079 @RenderLayoutImageTop(paragraph) 2080 break; 2081 } 2082 } 2083 </div> 2084 } 2085 } 2086 2087 2088 @helper RenderLayoutTitleTop(ContentParagraph settings) 2089 { 2090 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2091 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2092 @if (!settings.SetImageAsBackground && settings.Image != null) 2093 { 2094 <div class="u-margin-bottom--lg"> 2095 @Render(settings.Image) 2096 </div> 2097 } 2098 @Render(new Text { Content = settings.Text}) 2099 @Render(new ContentModule { Content = settings.Module }) 2100 2101 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2102 { 2103 <div class="grid__cell"> 2104 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2105 @Render(settings.ButtonPrimary) 2106 @Render(settings.ButtonSecondary) 2107 </div> 2108 </div> 2109 } 2110 </div> 2111 } 2112 2113 @helper RenderLayoutImageLeft(ContentParagraph settings) 2114 { 2115 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2116 <div class="grid grid--external-bleed"> 2117 @if (!settings.SetImageAsBackground && settings.Image != null) 2118 { 2119 <div class="grid__col-3"> 2120 @Render(settings.Image) 2121 </div> 2122 } 2123 <div class="grid__col-9 @settings.InnerPaddingCss dw-mod"> 2124 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2125 @Render(new Text { Content = settings.Text }) 2126 @Render(new ContentModule { Content = settings.Module }) 2127 2128 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2129 { 2130 <div class="grid__cell"> 2131 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2132 @Render(settings.ButtonPrimary) 2133 @Render(settings.ButtonSecondary) 2134 </div> 2135 </div> 2136 } 2137 </div> 2138 </div> 2139 </div> 2140 } 2141 2142 @helper RenderLayoutImageRight(ContentParagraph settings) 2143 { 2144 <div class="grid__cell @settings.CardCss"> 2145 <div class="grid grid--external-bleed"> 2146 <div class="grid__col-9 @settings.InnerPaddingCss dw-mod"> 2147 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2148 @Render(new Text { Content = settings.Text }) 2149 @Render(new ContentModule { Content = settings.Module }) 2150 2151 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2152 { 2153 <div class="grid__cell"> 2154 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2155 @Render(settings.ButtonPrimary) 2156 @Render(settings.ButtonSecondary) 2157 </div> 2158 </div> 2159 } 2160 </div> 2161 @if (!settings.SetImageAsBackground && settings.Image != null) 2162 { 2163 <div class="grid__col-3"> 2164 @Render(settings.Image) 2165 </div> 2166 } 2167 </div> 2168 </div> 2169 } 2170 2171 @helper RenderLayoutImageCentered(ContentParagraph settings) 2172 { 2173 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2174 2175 <div class="u-ta-center"> 2176 @if (!settings.SetImageAsBackground && settings.Image != null) 2177 { 2178 <div class="u-margin-bottom--lg u-inline-block"> 2179 @Render(settings.Image) 2180 </div> 2181 } 2182 </div> 2183 2184 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2185 @Render(new Text { Content = settings.Text }) 2186 @Render(new ContentModule { Content = settings.Module }) 2187 2188 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2189 { 2190 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2191 @Render(settings.ButtonPrimary) 2192 @Render(settings.ButtonSecondary) 2193 </div> 2194 } 2195 </div> 2196 } 2197 2198 @helper RenderLayoutAllCentered(ContentParagraph settings) 2199 { 2200 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2201 2202 <div class="u-ta-center"> 2203 @if (!settings.SetImageAsBackground && settings.Image != null) 2204 { 2205 <div class="u-margin-bottom--lg u-inline-block"> 2206 @Render(settings.Image) 2207 </div> 2208 } 2209 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2210 @Render(new Text { Content = settings.Text }) 2211 @Render(new ContentModule { Content = settings.Module }) 2212 </div> 2213 2214 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2215 { 2216 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2217 @Render(settings.ButtonPrimary) 2218 @Render(settings.ButtonSecondary) 2219 </div> 2220 } 2221 </div> 2222 } 2223 2224 @helper RenderLayoutMiddle(ContentParagraph settings) 2225 { 2226 <div> 2227 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2228 2229 <div class="@(settings.Layout == "middle-center" ? "u-ta-center" : "")"> 2230 @if (!settings.SetImageAsBackground && settings.Image != null) 2231 { 2232 <div class="u-margin-bottom--lg u-inline-block"> 2233 @Render(settings.Image) 2234 </div> 2235 } 2236 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2237 @Render(new Text { Content = settings.Text }) 2238 @Render(new ContentModule { Content = settings.Module }) 2239 </div> 2240 2241 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2242 { 2243 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2244 @Render(settings.ButtonPrimary) 2245 @Render(settings.ButtonSecondary) 2246 </div> 2247 } 2248 </div> 2249 </div> 2250 } 2251 2252 @helper RenderLayoutImageTop(ContentParagraph settings) 2253 { 2254 <div class="grid__cell @settings.CardCss"> 2255 @if (!settings.SetImageAsBackground && settings.Image != null) 2256 { 2257 <div class="u-margin-bottom--lg"> 2258 @Render(settings.Image) 2259 </div> 2260 } 2261 2262 <div class="@settings.InnerPaddingCss dw-mod"> 2263 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2264 @Render(new Text { Content = settings.Text }) 2265 @Render(new ContentModule { Content = settings.Module }) 2266 2267 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2268 { 2269 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2270 @Render(settings.ButtonPrimary) 2271 @Render(settings.ButtonSecondary) 2272 </div> 2273 } 2274 </div> 2275 </div> 2276 } 2277 2278 2279 @{ 2280 string fontColor = !string.IsNullOrEmpty(Model.Item.GetString("FontColor")) && !Model.Item.GetString("FontColor").StartsWith("#") ? "u-" + Model.Item.GetString("FontColor").Replace(" ", "-").ToLower() : ""; 2281 string backgroundColor = !string.IsNullOrEmpty(Model.Item.GetString("BackgroundColor")) && !Model.Item.GetString("BackgroundColor").StartsWith("#") ? "u-" + Model.Item.GetString("BackgroundColor").Replace(" ", "-").ToLower() + "--bg" : ""; 2282 string colorSettings = Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "style=\"" : ""; 2283 string fontColorHex = Model.Item.GetString("FontColor").StartsWith("#") ? "color: " + Model.Item.GetString("FontColor") + ";" : ""; 2284 string backgroundColorHex = Model.Item.GetString("BackgroundColor").StartsWith("#") ? "background-color: " + Model.Item.GetString("BackgroundColor") + ";" : ""; 2285 colorSettings += fontColorHex; 2286 colorSettings += backgroundColorHex; 2287 colorSettings += Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "\"" : ""; 2288 2289 string paragraphContainerClasses = ""; 2290 string containerClasses = ""; 2291 string gridClasses = ""; 2292 2293 string spacingSize = Model.Item.GetList("Spacing") != null && Model.Item.GetList("Spacing").SelectedValue != "" ? Model.Item.GetList("Spacing").SelectedValue : "lg"; 2294 2295 switch (Model.Item.GetList("Width").SelectedValue) 2296 { 2297 case "center": 2298 containerClasses += "center-container paragraph-container "; 2299 paragraphContainerClasses += " " + fontColor + " " + backgroundColor; 2300 break; 2301 case "full": 2302 containerClasses += fontColor + " " + backgroundColor + " "; 2303 paragraphContainerClasses += "paragraph-container--full-width "; 2304 break; 2305 case "combi": 2306 paragraphContainerClasses += "paragraph-container--full-width " + fontColor + " " + backgroundColor + " "; 2307 containerClasses += "center-container paragraph-container "; 2308 break; 2309 default: 2310 paragraphContainerClasses += "center-container "; 2311 break; 2312 } 2313 2314 //Background 2315 string focalPointParameters = Model.Item.GetFile("BackgroundImage") != null ? "&" + Model.Item.GetFile("BackgroundImage").GetFocalPointParameters() : ""; 2316 2317 string containerBackgroundImageFilterColor = Model.Item.GetList("ColorForTheFilter") != null ? Model.Item.GetString("ColorForTheFilter").Replace(" ", "-").ToLower() : "none"; 2318 string containerBackgroundImageFilterPrimary = Model.Item.GetList("ImageFilterPrimary") != null ? Model.Item.GetList("ImageFilterPrimary").SelectedValue : "none"; 2319 string containerBackgroundImageFilterSecondary = Model.Item.GetList("ImageFilterSecondary") != null ? Model.Item.GetList("ImageFilterSecondary").SelectedValue : "none"; 2320 string containerBackgroundImageFilterColorCode = Model.Item.GetString("ColorForTheFilter").StartsWith("#") && containerBackgroundImageFilterPrimary == "colorize" ? "style=\"background-color: " + GenerateRgba(Model.Item.GetString("ColorForTheFilter"), 0.3) + "\"" : ""; 2321 2322 if (containerBackgroundImageFilterPrimary == "colorize" && !containerBackgroundImageFilterPrimary.StartsWith("#")) 2323 { 2324 containerBackgroundImageFilterPrimary = containerBackgroundImageFilterColor; 2325 } 2326 2327 if (Model.Item.GetFile("BackgroundImage") == null) { 2328 backgroundColor = "u-color-light--bg"; 2329 } 2330 2331 //Separation line 2332 bool hasSeparationLine = Model.Item.GetBoolean("SeperationLineAfter"); 2333 if (hasSeparationLine && Model.Item.GetList("Width").SelectedValue != "center") 2334 { 2335 paragraphContainerClasses += "multiple-paragraphs-container--seperation-line-after "; 2336 } 2337 else if (hasSeparationLine) 2338 { 2339 containerClasses += "multiple-paragraphs-container--seperation-line-after "; 2340 } 2341 2342 //Alternative Design Layout 2343 var designLayout = Model.Item.GetItem("CustomSettings") != null ? Model.Item.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.Item.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 2344 paragraphContainerClasses += !String.IsNullOrEmpty(designLayout) ? designLayout : ""; 2345 2346 var paragraphHeight = Model.Item.GetList("Height").SelectedValue; 2347 //Height 2348 if (!string.IsNullOrEmpty(paragraphHeight)) 2349 { 2350 gridClasses += "paragraph-container--height-" + paragraphHeight + " " + (paragraphHeight == "screen" ? "screen-height " : ""); 2351 } 2352 2353 if (Model.Item.GetString("MakeParagraphsCenterAligned") != null && Model.Item.GetBoolean("MakeParagraphsCenterAligned")) 2354 { 2355 gridClasses += "grid--justify-center "; 2356 } 2357 2358 //Set as carousel 2359 if (Model.Item.GetBoolean("EnableCarousel")) 2360 { 2361 containerClasses.Replace(" paragraph-container ", ""); 2362 } 2363 2364 //getting video ID from youtube URL 2365 string videoCode = Model.Item.GetString("VideoURL"); 2366 Regex regex = new Regex(@".be\/(.[^?]*)"); 2367 Match match = regex.Match(videoCode); 2368 string videoId = ""; 2369 if (match.Success) 2370 { 2371 videoId = match.Groups[1].Value; 2372 } 2373 else 2374 { 2375 regex = new Regex(@"v=([^&]+)"); 2376 match = regex.Match(videoCode); 2377 if (match.Success) 2378 { 2379 videoId = match.Groups[1].Value; 2380 } 2381 } 2382 } 2383 2384 <div class="grid__col-md-12 grid__col--bleed"> 2385 <section class="multiple-paragraphs-container @paragraphContainerClasses multiple-paragraphs-container--spacing-@spacingSize dw-mod" @colorSettings> 2386 <div class="background-image image-filter image-filter--@containerBackgroundImageFilterPrimary dw-mod" @containerBackgroundImageFilterColorCode> 2387 <div class="background-image__wrapper image-filter image-filter--@containerBackgroundImageFilterSecondary dw-mod"> 2388 @if (!String.IsNullOrEmpty(Model.Item.GetString("BackgroundImage"))) { 2389 @Render(new Image { 2390 Path = Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters, 2391 CssClass = "background-image__cover", 2392 ImageDefault = new ImageSettings { 2393 Width = 1920, 2394 Height = 845, 2395 Crop = 0, 2396 FillCanvas = true 2397 }, 2398 ImageMedium = new ImageSettings 2399 { 2400 Width = 1024, 2401 Height = 450, 2402 Crop = 0, 2403 FillCanvas = true 2404 }, 2405 ImageSmall = new ImageSettings 2406 { 2407 Width = 640, 2408 Height = 544, 2409 Crop = 0, 2410 FillCanvas = true 2411 } 2412 }) 2413 } 2414 2415 @if (!string.IsNullOrEmpty(videoId)) 2416 { 2417 <div class="video-background"> 2418 <div class="video-background__container"> 2419 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Model.ID)"></div> 2420 </div> 2421 </div> 2422 } 2423 </div> 2424 </div> 2425 2426 @if (!Model.Item.GetBoolean("EnableCarousel")) 2427 { 2428 <div class="@containerClasses dw-mod"> 2429 <div class="grid @gridClasses dw-mod"> 2430 @foreach (var paragraph in Model.Item.GetItems("Paragraph")) 2431 { 2432 @RenderParagraph(paragraph, false) 2433 } 2434 @if (!String.IsNullOrEmpty(Model.GetModuleOutput())) { 2435 <div class="paragraph-container grid__col-12 dw-mod"> 2436 @Render(new ContentModule { Content = Model.GetModuleOutput() }) 2437 </div> 2438 } 2439 </div> 2440 </div> 2441 } 2442 else 2443 { 2444 var slides = new List<List<Dynamicweb.Frontend.ItemViewModel>>(); 2445 int tempColumnsCount = 0; 2446 var paragraphs = Model.Item.GetItems("Paragraph"); 2447 bool hasAtLeastOneVisibleParagraph = false; 2448 if (paragraphs.Count > 0) 2449 { 2450 slides.Add(new List<Dynamicweb.Frontend.ItemViewModel>()); 2451 } 2452 2453 foreach (var paragraph in paragraphs) 2454 { 2455 int columnWidth = 0; 2456 if (Pageview.Device.ToString() == "Mobile" && paragraph.GetList("WidthMobile").SelectedValue == "hide") 2457 { 2458 continue; 2459 } 2460 hasAtLeastOneVisibleParagraph = true; 2461 if (paragraph.GetList("Width").SelectedValue != "auto") 2462 { 2463 columnWidth = Pageview.Device.ToString() != "Mobile" ? Int32.Parse(paragraph.GetList("Width").SelectedValue) : Int32.Parse(paragraph.GetList("WidthMobile").SelectedValue); 2464 } 2465 else 2466 { 2467 columnWidth = 1; 2468 } 2469 2470 if (tempColumnsCount + columnWidth > 12) 2471 { 2472 slides.Add(new List<Dynamicweb.Frontend.ItemViewModel>()); 2473 tempColumnsCount = 0; 2474 } 2475 2476 slides[slides.Count - 1].Add(paragraph); 2477 tempColumnsCount += columnWidth; 2478 } 2479 2480 if (hasAtLeastOneVisibleParagraph) 2481 { 2482 <div class="@containerClasses dw-mod"> 2483 <div class="carousel dw-mod" id="Paragraph_@(Model.ID)"> 2484 <div class="carousel__container js-carousel-slides dw-mod"> 2485 @foreach (var slide in slides) 2486 { 2487 <div class="carousel__slide dw-mod"> 2488 <div class="grid @gridClasses dw-mod"> 2489 @foreach (var paragraph in slide) 2490 { 2491 @RenderParagraph(paragraph, false) 2492 } 2493 </div> 2494 </div> 2495 } 2496 </div> 2497 </div> 2498 </div> 2499 } 2500 2501 if (slides.Count > 1) 2502 { 2503 bool enableDots = Model.Item.GetBoolean("ShowDots"); 2504 2505 <script> 2506 document.addEventListener("DOMContentLoaded", function () { 2507 new CarouselModule("#Paragraph_@(Model.ID)", { 2508 slideTime: @Model.Item.GetString("SlideTime"), 2509 dots: @(Model.Item.GetBoolean("ShowDots").ToString().ToLower()) 2510 }); 2511 }) 2512 </script> 2513 } 2514 } 2515 </section> 2516 </div> 2517
Countries

Premium solution partner

Solution partners

Business partners