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

Logout

Error executing template "Designs/Rapido/Paragraph/DynamicArticleListParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_1eb86fafc602494c8c8a3f22421ecc81.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\Paragraph\DynamicArticleListParagraph.cshtml:line 90
   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.IO 3 @using System.Web 4 @using Dynamicweb.Rapido.Blocks.Components 5 @using Dynamicweb.Rapido.Blocks.Components.Articles 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 @using Dynamicweb.Rapido.Blocks 8 9 @{ 10 string blocksPageName = "ArticleListParagraph" + Pageview.CurrentParagraph.ID.ToString(); 11 BlocksPage articleListParagraph = BlocksPage.GetBlockPage(blocksPageName); 12 13 14 int pageId = Model.PageID; 15 bool showTitle = Model.Item.GetBoolean("ShowTitle"); 16 string dynamicListWidth = "12"; 17 string itemType = Model.Item.GetString("ItemTypeName") != null ? Model.Item.GetString("ItemTypeName") : "DynamicArticle"; 18 19 Block listPageContainer = new Block 20 { 21 Id = "ArticleListParagraphContainer", 22 SortId = 10, 23 Design = new Design 24 { 25 RenderType = RenderType.Row 26 }, 27 BlocksList = new List<Block> { 28 new Block { 29 Id = "ArticleListParagraphHeader", 30 SortId = 20, 31 Design = new Design 32 { 33 RenderType = RenderType.Column, 34 Size = "12" 35 }, 36 BlocksList = new List<Block> { 37 new Block { 38 Id = "ArticleListParagraphHeaderRow", 39 SortId = 10, 40 Design = new Design 41 { 42 RenderType = RenderType.Row, 43 HidePadding = true 44 } 45 } 46 } 47 } 48 } 49 }; 50 articleListParagraph.Add(listPageContainer); 51 52 if (showTitle) { 53 Block titleBlock = new Block 54 { 55 Id = "ArticleListTitle", 56 SortId = 10, 57 Component = new Heading { Title = Model.Item.GetString("Title"), Level = 2, CssClass = "u-no-margin" }, 58 Design = new Design 59 { 60 RenderType = RenderType.Column, 61 Size = "12" 62 } 63 }; 64 articleListParagraph.Add("ArticleListParagraphHeaderRow", titleBlock); 65 } 66 67 Block listBody = new Block 68 { 69 Id = "ArticleListParagraphBody", 70 SortId = 30, 71 Design = new Design 72 { 73 RenderType = RenderType.Column, 74 Size = dynamicListWidth 75 } 76 }; 77 articleListParagraph.Add("ArticleListParagraphContainer", listBody); 78 79 Block listBodyRow = new Block 80 { 81 Id = "ArticleListParagraphBodyRow", 82 SortId = 10, 83 Design = new Design 84 { 85 RenderType = RenderType.Row 86 } 87 }; 88 articleListParagraph.Add("ArticleListParagraphBody", listBodyRow); 89 90 Block listMain = new Block 91 { 92 Id = "ArticleListMain", 93 SortId = 20, 94 Component = new ArticleList { Template = "../ItemPublisher/List/DynamicList.cshtml", PageSize = Model.Item.GetInt32("ArticlesListSize"), DisablePagination = true, SourcePage = Model.Item.GetItem("GetArticlesFrom").PageID.ToString(), SourceType = "Page", ItemType = itemType }, 95 Design = new Design 96 { 97 RenderType = RenderType.Column, 98 Size = "12", 99 HidePadding = true 100 } 101 }; 102 articleListParagraph.Add("ArticleListParagraphBodyRow", listMain); 103 } 104 105 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 106 @using System.Text.RegularExpressions 107 @using System.Collections.Generic 108 @using System.Reflection 109 @using System.Web 110 @using System.Web.UI.HtmlControls 111 @using Dynamicweb.Rapido.Blocks.Components 112 @using Dynamicweb.Rapido.Blocks.Components.Articles 113 @using Dynamicweb.Rapido.Blocks.Components.Documentation 114 @using Dynamicweb.Rapido.Blocks 115 116 117 @*--- START: Base block renderers ---*@ 118 119 @helper RenderBlockList(List<Block> blocks) 120 { 121 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 122 blocks = blocks.OrderBy(item => item.SortId).ToList(); 123 124 foreach (Block item in blocks) 125 { 126 if (debug) { 127 <!-- Block START: @item.Id --> 128 } 129 130 if (item.Design == null) 131 { 132 @RenderBlock(item) 133 } 134 else if (item.Design.RenderType == RenderType.None) { 135 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 136 137 <div class="@cssClass dw-mod"> 138 @RenderBlock(item) 139 </div> 140 } 141 else if (item.Design.RenderType != RenderType.Hide) 142 { 143 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 144 145 if (!item.SkipRenderBlocksList) { 146 if (item.Design.RenderType == RenderType.Row) 147 { 148 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 149 @RenderBlock(item) 150 </div> 151 } 152 153 if (item.Design.RenderType == RenderType.Column) 154 { 155 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 156 string size = item.Design.Size ?? "12"; 157 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 158 159 <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"> 160 @RenderBlock(item) 161 </div> 162 } 163 164 if (item.Design.RenderType == RenderType.Table) 165 { 166 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 167 @RenderBlock(item) 168 </table> 169 } 170 171 if (item.Design.RenderType == RenderType.TableRow) 172 { 173 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 174 @RenderBlock(item) 175 </tr> 176 } 177 178 if (item.Design.RenderType == RenderType.TableColumn) 179 { 180 <td class="@cssClass dw-mod" id="Block__@item.Id"> 181 @RenderBlock(item) 182 </td> 183 } 184 185 if (item.Design.RenderType == RenderType.CardHeader) 186 { 187 <div class="card-header @cssClass dw-mod"> 188 @RenderBlock(item) 189 </div> 190 } 191 192 if (item.Design.RenderType == RenderType.CardBody) 193 { 194 <div class="card @cssClass dw-mod"> 195 @RenderBlock(item) 196 </div> 197 } 198 199 if (item.Design.RenderType == RenderType.CardFooter) 200 { 201 <div class="card-footer @cssClass dw-mod"> 202 @RenderBlock(item) 203 </div> 204 } 205 } 206 else 207 { 208 @RenderBlock(item) 209 } 210 } 211 212 if (debug) { 213 <!-- Block END: @item.Id --> 214 } 215 } 216 } 217 218 @helper RenderBlock(Block item) 219 { 220 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 221 222 if (item.Template != null) 223 { 224 @BlocksPage.RenderTemplate(item.Template) 225 } 226 227 if (item.Component != null) 228 { 229 string customSufix = "Custom"; 230 string methodName = item.Component.HelperName; 231 232 ComponentBase[] methodParameters = new ComponentBase[1]; 233 methodParameters[0] = item.Component; 234 Type methodType = this.GetType(); 235 236 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 237 MethodInfo generalMethod = methodType.GetMethod(methodName); 238 239 try { 240 if (debug) { 241 <!-- Component: @methodName.Replace("Render", "") --> 242 } 243 @customMethod.Invoke(this, methodParameters).ToString(); 244 } catch { 245 try { 246 @generalMethod.Invoke(this, methodParameters).ToString(); 247 } catch(Exception ex) { 248 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 249 } 250 } 251 } 252 253 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 254 { 255 @RenderBlockList(item.BlocksList) 256 } 257 } 258 259 @*--- END: Base block renderers ---*@ 260 261 262 @* Include the components *@ 263 @using Dynamicweb.Rapido.Blocks.Components 264 @using Dynamicweb.Rapido.Blocks.Components.General 265 @using Dynamicweb.Rapido.Blocks 266 @using System.IO 267 268 @* Required *@ 269 @using Dynamicweb.Rapido.Blocks.Components 270 @using Dynamicweb.Rapido.Blocks.Components.General 271 @using Dynamicweb.Rapido.Blocks 272 273 274 @helper Render(ComponentBase component) 275 { 276 if (component != null) 277 { 278 @component.Render(this) 279 } 280 } 281 282 283 @* Components *@ 284 @using System.Reflection 285 @using Dynamicweb.Rapido.Blocks.Components.General 286 287 288 @* Component *@ 289 290 @helper RenderIcon(Icon settings) 291 { 292 if (settings != null) 293 { 294 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 295 296 if (settings.Name != null) 297 { 298 if (string.IsNullOrEmpty(settings.Label)) 299 { 300 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 301 } 302 else 303 { 304 if (settings.LabelPosition == IconLabelPosition.Before) 305 { 306 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 307 } 308 else 309 { 310 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 311 } 312 } 313 } 314 else if (!string.IsNullOrEmpty(settings.Label)) 315 { 316 @settings.Label 317 } 318 } 319 } 320 @using System.Reflection 321 @using Dynamicweb.Rapido.Blocks.Components.General 322 @using Dynamicweb.Rapido.Blocks.Components 323 @using Dynamicweb.Core 324 325 @* Component *@ 326 327 @helper RenderButton(Button settings) 328 { 329 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 330 { 331 Dictionary<string, string> attributes = new Dictionary<string, string>(); 332 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 333 if (settings.Disabled) { 334 attributes.Add("disabled", "true"); 335 classList.Add("disabled"); 336 } 337 338 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 339 { 340 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 341 @RenderConfirmDialog(settings); 342 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 343 } 344 345 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 346 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 347 if (!string.IsNullOrEmpty(settings.AltText)) 348 { 349 attributes.Add("title", settings.AltText); 350 } 351 else if (!string.IsNullOrEmpty(settings.Title)) 352 { 353 attributes.Add("title", settings.Title); 354 } 355 356 var onClickEvents = new List<string>(); 357 if (!string.IsNullOrEmpty(settings.OnClick)) 358 { 359 onClickEvents.Add(settings.OnClick); 360 } 361 if (!string.IsNullOrEmpty(settings.Href)) 362 { 363 onClickEvents.Add("location.href='" + settings.Href + "'"); 364 } 365 if (onClickEvents.Count > 0) 366 { 367 attributes.Add("onClick", string.Join(";", onClickEvents)); 368 } 369 370 if (settings.ButtonLayout != ButtonLayout.None) 371 { 372 classList.Add("btn"); 373 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 374 if (btnLayout == "linkclean") 375 { 376 btnLayout = "link-clean"; //fix 377 } 378 classList.Add("btn--" + btnLayout); 379 } 380 381 if (settings.Icon == null) 382 { 383 settings.Icon = new Icon(); 384 } 385 settings.Icon.Label = settings.Title; 386 387 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 388 389 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 390 } 391 } 392 393 @helper RenderConfirmDialog(Button settings) 394 { 395 Modal confirmDialog = new Modal { 396 Id = settings.Id, 397 Width = ModalWidth.Sm, 398 Heading = new Heading 399 { 400 Level = 2, 401 Title = settings.ConfirmTitle 402 }, 403 BodyText = settings.ConfirmText 404 }; 405 406 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 407 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 408 409 @Render(confirmDialog) 410 } 411 @using Dynamicweb.Rapido.Blocks.Components.General 412 @using Dynamicweb.Rapido.Blocks.Components 413 @using Dynamicweb.Core 414 415 @helper RenderDashboard(Dashboard settings) 416 { 417 var widgets = settings.GetWidgets(); 418 419 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 420 { 421 //set bg color for them 422 423 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 424 int r = Convert.ToInt16(color.R); 425 int g = Convert.ToInt16(color.G); 426 int b = Convert.ToInt16(color.B); 427 428 var count = widgets.Length; 429 var max = Math.Max(r, Math.Max(g, b)); 430 double step = 255.0 / (max * count); 431 var i = 0; 432 foreach (var widget in widgets) 433 { 434 i++; 435 436 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 437 widget.BackgroundColor = shade; 438 } 439 } 440 441 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 442 @foreach (var widget in widgets) 443 { 444 <div class="dashboard__widget"> 445 @Render(widget) 446 </div> 447 } 448 </div> 449 } 450 @using Dynamicweb.Rapido.Blocks.Components.General 451 @using Dynamicweb.Rapido.Blocks.Components 452 453 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 454 { 455 if (!string.IsNullOrEmpty(settings.Link)) 456 { 457 var backgroundStyles = ""; 458 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 459 { 460 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 461 } 462 463 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 464 <div class="u-center-middle u-color-light"> 465 @if (settings.Icon != null) 466 { 467 settings.Icon.CssClass += "widget__icon"; 468 @Render(settings.Icon) 469 } 470 <div class="widget__title">@settings.Title</div> 471 </div> 472 </a> 473 } 474 } 475 @using Dynamicweb.Rapido.Blocks.Components.General 476 @using Dynamicweb.Rapido.Blocks.Components 477 478 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 479 { 480 var backgroundStyles = ""; 481 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 482 { 483 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 484 } 485 486 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 487 <div class="u-center-middle u-color-light"> 488 @if (settings.Icon != null) 489 { 490 settings.Icon.CssClass += "widget__icon"; 491 @Render(settings.Icon) 492 } 493 <div class="widget__counter">@settings.Count</div> 494 <div class="widget__title">@settings.Title</div> 495 </div> 496 </div> 497 } 498 @using System.Reflection 499 @using Dynamicweb.Rapido.Blocks.Components.General 500 @using Dynamicweb.Rapido.Blocks.Components 501 @using Dynamicweb.Core 502 503 @* Component *@ 504 505 @helper RenderLink(Link settings) 506 { 507 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 508 { 509 Dictionary<string, string> attributes = new Dictionary<string, string>(); 510 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 511 if (settings.Disabled) 512 { 513 attributes.Add("disabled", "true"); 514 classList.Add("disabled"); 515 } 516 517 if (!string.IsNullOrEmpty(settings.AltText)) 518 { 519 attributes.Add("title", settings.AltText); 520 } 521 else if (!string.IsNullOrEmpty(settings.Title)) 522 { 523 attributes.Add("title", settings.Title); 524 } 525 526 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 527 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 528 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 529 attributes.Add("href", settings.Href); 530 531 if (settings.ButtonLayout != ButtonLayout.None) 532 { 533 classList.Add("btn"); 534 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 535 if (btnLayout == "linkclean") 536 { 537 btnLayout = "link-clean"; //fix 538 } 539 classList.Add("btn--" + btnLayout); 540 } 541 542 if (settings.Icon == null) 543 { 544 settings.Icon = new Icon(); 545 } 546 settings.Icon.Label = settings.Title; 547 548 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 549 { 550 settings.Rel = LinkRelType.Noopener; 551 } 552 if (settings.Target != LinkTargetType.None) 553 { 554 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 555 } 556 if (settings.Download) 557 { 558 attributes.Add("download", "true"); 559 } 560 if (settings.Rel != LinkRelType.None) 561 { 562 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 563 } 564 565 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 566 } 567 } 568 @using System.Reflection 569 @using Dynamicweb.Rapido.Blocks.Components 570 @using Dynamicweb.Rapido.Blocks.Components.General 571 @using Dynamicweb.Rapido.Blocks 572 573 574 @* Component *@ 575 576 @helper RenderRating(Rating settings) 577 { 578 if (settings.Score > 0) 579 { 580 int rating = settings.Score; 581 string iconType = "fa-star"; 582 583 switch (settings.Type.ToString()) { 584 case "Stars": 585 iconType = "fa-star"; 586 break; 587 case "Hearts": 588 iconType = "fa-heart"; 589 break; 590 case "Lemons": 591 iconType = "fa-lemon"; 592 break; 593 case "Bombs": 594 iconType = "fa-bomb"; 595 break; 596 } 597 598 <div class="u-ta-right"> 599 @for (int i = 0; i < settings.OutOf; i++) 600 { 601 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 602 } 603 </div> 604 } 605 } 606 @using System.Reflection 607 @using Dynamicweb.Rapido.Blocks.Components.General 608 @using Dynamicweb.Rapido.Blocks.Components 609 610 611 @* Component *@ 612 613 @helper RenderSelectFieldOption(SelectFieldOption settings) 614 { 615 Dictionary<string, string> attributes = new Dictionary<string, string>(); 616 if (settings.Checked) { attributes.Add("selected", "true"); } 617 if (settings.Disabled) { attributes.Add("disabled", "true"); } 618 if (settings.Value != null) { attributes.Add("value", settings.Value); } 619 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 620 621 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 622 } 623 @using System.Reflection 624 @using Dynamicweb.Rapido.Blocks.Components.General 625 @using Dynamicweb.Rapido.Blocks.Components 626 627 628 @* Component *@ 629 630 @helper RenderNavigation(Navigation settings) { 631 @RenderNavigation(new 632 { 633 id = settings.Id, 634 cssclass = settings.CssClass, 635 startLevel = settings.StartLevel, 636 endlevel = settings.EndLevel, 637 expandmode = settings.Expandmode, 638 sitemapmode = settings.SitemapMode, 639 template = settings.Template 640 }) 641 } 642 @using Dynamicweb.Rapido.Blocks.Components.General 643 @using Dynamicweb.Rapido.Blocks.Components 644 645 646 @* Component *@ 647 648 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 649 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 650 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 651 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 652 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 653 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 654 settings.SitemapMode = false; 655 656 @RenderNavigation(settings) 657 } 658 @using Dynamicweb.Rapido.Blocks.Components.General 659 @using Dynamicweb.Rapido.Blocks.Components 660 661 662 @* Component *@ 663 664 @helper RenderLeftNavigation(LeftNavigation settings) { 665 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 666 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 667 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 668 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 669 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 670 671 <div class="grid__cell"> 672 @RenderNavigation(settings) 673 </div> 674 } 675 @using System.Reflection 676 @using Dynamicweb.Rapido.Blocks.Components.General 677 @using Dynamicweb.Core 678 679 @* Component *@ 680 681 @helper RenderHeading(Heading settings) 682 { 683 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 684 { 685 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 686 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 687 688 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 689 if (!string.IsNullOrEmpty(settings.Link)) 690 { 691 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 692 } 693 else 694 { 695 if (settings.Icon == null) 696 { 697 settings.Icon = new Icon(); 698 } 699 settings.Icon.Label = settings.Title; 700 @Render(settings.Icon) 701 } 702 @("</" + tagName + ">"); 703 } 704 } 705 @using Dynamicweb.Rapido.Blocks.Components 706 @using Dynamicweb.Rapido.Blocks.Components.General 707 @using Dynamicweb.Rapido.Blocks 708 709 710 @* Component *@ 711 712 @helper RenderImage(Image settings) 713 { 714 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 715 { 716 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 717 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 718 719 if (settings.Caption != null) 720 { 721 @:<div> 722 } 723 724 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 725 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 726 727 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 728 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 729 @if (settings.Link != null) 730 { 731 <a href="@settings.Link"> 732 @RenderTheImage(settings) 733 </a> 734 } 735 else 736 { 737 @RenderTheImage(settings) 738 } 739 </div> 740 </div> 741 742 if (settings.Caption != null) 743 { 744 <span class="image-caption dw-mod">@settings.Caption</span> 745 @:</div> 746 } 747 } 748 else 749 { 750 if (settings.Caption != null) 751 { 752 @:<div> 753 } 754 if (!string.IsNullOrEmpty(settings.Link)) 755 { 756 <a href="@settings.Link"> 757 @RenderTheImage(settings) 758 </a> 759 } 760 else 761 { 762 @RenderTheImage(settings) 763 } 764 765 if (settings.Caption != null) 766 { 767 <span class="image-caption dw-mod">@settings.Caption</span> 768 @:</div> 769 } 770 } 771 } 772 773 @helper RenderTheImage(Image settings) 774 { 775 if (settings != null) 776 { 777 string placeholderImage = "/Files/Images/placeholder.gif"; 778 string imageEngine = "/Admin/Public/GetImage.ashx?"; 779 780 string imageStyle = ""; 781 782 switch (settings.Style) 783 { 784 case ImageStyle.Ball: 785 imageStyle = "grid__cell-img--ball"; 786 break; 787 } 788 789 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 790 { 791 if (settings.ImageDefault != null) 792 { 793 settings.ImageDefault.Height = settings.ImageDefault.Width; 794 } 795 if (settings.ImageMedium != null) 796 { 797 settings.ImageMedium.Height = settings.ImageMedium.Width; 798 } 799 if (settings.ImageSmall != null) 800 { 801 settings.ImageSmall.Height = settings.ImageSmall.Width; 802 } 803 } 804 805 string defaultImage = imageEngine; 806 string imageSmall = ""; 807 string imageMedium = ""; 808 809 if (settings.DisableImageEngine) 810 { 811 defaultImage = settings.Path; 812 } 813 else 814 { 815 if (settings.ImageDefault != null) 816 { 817 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 818 819 if (settings.Path.GetType() != typeof(string)) 820 { 821 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 822 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 823 } 824 else 825 { 826 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 827 } 828 } 829 830 if (settings.ImageSmall != null) 831 { 832 imageSmall = "data-src-small=\"" + imageEngine; 833 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 834 835 if (settings.Path.GetType() != typeof(string)) 836 { 837 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 838 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 839 } 840 else 841 { 842 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 843 } 844 845 imageSmall += "\""; 846 } 847 848 if (settings.ImageMedium != null) 849 { 850 imageMedium = "data-src-medium=\"" + imageEngine; 851 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 852 853 if (settings.Path.GetType() != typeof(string)) 854 { 855 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 856 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 857 } 858 else 859 { 860 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 861 } 862 863 imageMedium += "\""; 864 } 865 } 866 867 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 868 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 869 if (!string.IsNullOrEmpty(settings.Title)) 870 { 871 optionalAttributes.Add("alt", settings.Title); 872 optionalAttributes.Add("title", settings.Title); 873 } 874 875 if (settings.DisableLazyLoad) 876 { 877 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 878 } 879 else 880 { 881 <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) /> 882 } 883 } 884 } 885 @using System.Reflection 886 @using Dynamicweb.Rapido.Blocks.Components.General 887 @using Dynamicweb.Rapido.Blocks.Components 888 889 @* Component *@ 890 891 @helper RenderFileField(FileField settings) 892 { 893 var attributes = new Dictionary<string, string>(); 894 if (string.IsNullOrEmpty(settings.Id)) 895 { 896 settings.Id = Guid.NewGuid().ToString("N"); 897 } 898 899 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 900 if (settings.Disabled) { attributes.Add("disabled", "true"); } 901 if (settings.Required) { attributes.Add("required", "true"); } 902 if (settings.Multiple) { attributes.Add("multiple", "true"); } 903 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 904 if (string.IsNullOrEmpty(settings.ChooseFileText)) 905 { 906 settings.ChooseFileText = Translate("Choose file"); 907 } 908 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 909 { 910 settings.NoFilesChosenText = Translate("No files chosen..."); 911 } 912 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 913 914 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 915 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 916 917 attributes.Add("type", "file"); 918 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 919 settings.CssClass = "u-full-width " + settings.CssClass; 920 921 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 922 923 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 924 @if (!string.IsNullOrEmpty(settings.Label)) 925 { 926 <label for="@settings.Id">@settings.Label</label> 927 } 928 @if (!string.IsNullOrEmpty(settings.HelpText)) 929 { 930 <small class="form__help-text">@settings.HelpText</small> 931 } 932 933 <div class="form__field-combi file-input u-no-margin dw-mod"> 934 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 935 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 936 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 937 @if (settings.UploadButton != null) 938 { 939 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 940 @Render(settings.UploadButton) 941 } 942 </div> 943 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 944 </div> 945 } 946 @using System.Reflection 947 @using Dynamicweb.Rapido.Blocks.Components.General 948 @using Dynamicweb.Rapido.Blocks.Components 949 @using Dynamicweb.Core 950 @using System.Linq 951 952 @* Component *@ 953 954 @helper RenderDateTimeField(DateTimeField settings) 955 { 956 if (string.IsNullOrEmpty(settings.Id)) 957 { 958 settings.Id = Guid.NewGuid().ToString("N"); 959 } 960 961 var textField = new TextField { 962 Name = settings.Name, 963 Id = settings.Id, 964 Label = settings.Label, 965 HelpText = settings.HelpText, 966 Value = settings.Value, 967 Disabled = settings.Disabled, 968 Required = settings.Required, 969 ErrorMessage = settings.ErrorMessage, 970 CssClass = settings.CssClass, 971 WrapperCssClass = settings.WrapperCssClass, 972 OnChange = settings.OnChange, 973 OnClick = settings.OnClick, 974 ExtraAttributes = settings.ExtraAttributes, 975 // 976 Placeholder = settings.Placeholder 977 }; 978 979 @Render(textField) 980 981 List<string> jsAttributes = new List<string>(); 982 983 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 984 985 if (!string.IsNullOrEmpty(settings.DateFormat)) 986 { 987 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 988 } 989 if (!string.IsNullOrEmpty(settings.MinDate)) 990 { 991 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 992 } 993 if (!string.IsNullOrEmpty(settings.MaxDate)) 994 { 995 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 996 } 997 if (settings.IsInline) 998 { 999 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1000 } 1001 if (settings.EnableTime) 1002 { 1003 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1004 } 1005 if (settings.EnableWeekNumbers) 1006 { 1007 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1008 } 1009 1010 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1011 1012 <script> 1013 document.addEventListener("DOMContentLoaded", function () { 1014 flatpickr("#@textField.Id", { 1015 @string.Join(",", jsAttributes) 1016 }); 1017 }); 1018 </script> 1019 } 1020 @using System.Reflection 1021 @using Dynamicweb.Rapido.Blocks.Components.General 1022 @using Dynamicweb.Rapido.Blocks.Components 1023 1024 @* Component *@ 1025 1026 @helper RenderTextField(TextField settings) 1027 { 1028 var attributes = new Dictionary<string, string>(); 1029 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1030 { 1031 settings.Id = Guid.NewGuid().ToString("N"); 1032 } 1033 1034 /*base settings*/ 1035 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1036 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1037 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1038 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1039 if (settings.Required) { attributes.Add("required", "true"); } 1040 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1041 /*end*/ 1042 1043 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1044 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1045 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1046 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1047 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1048 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1049 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1050 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1051 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1052 settings.CssClass = "u-full-width " + settings.CssClass; 1053 1054 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1055 1056 string noMargin = "u-no-margin"; 1057 if (!settings.ReadOnly) { 1058 noMargin = ""; 1059 } 1060 1061 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1062 @if (!string.IsNullOrEmpty(settings.Label)) 1063 { 1064 <label for="@settings.Id">@settings.Label</label> 1065 } 1066 @if (!string.IsNullOrEmpty(settings.HelpText)) 1067 { 1068 <small class="form__help-text">@settings.HelpText</small> 1069 } 1070 1071 @if (settings.ActionButton != null) 1072 { 1073 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1074 <div class="form__field-combi u-no-margin dw-mod"> 1075 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1076 @Render(settings.ActionButton) 1077 </div> 1078 } 1079 else 1080 { 1081 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1082 } 1083 1084 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1085 </div> 1086 } 1087 @using System.Reflection 1088 @using Dynamicweb.Rapido.Blocks.Components.General 1089 @using Dynamicweb.Rapido.Blocks.Components 1090 1091 @* Component *@ 1092 1093 @helper RenderNumberField(NumberField settings) 1094 { 1095 var attributes = new Dictionary<string, string>(); 1096 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1097 { 1098 settings.Id = Guid.NewGuid().ToString("N"); 1099 } 1100 1101 /*base settings*/ 1102 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1103 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1104 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1105 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1106 if (settings.Required) { attributes.Add("required", "true"); } 1107 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1108 /*end*/ 1109 1110 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1111 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1112 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1113 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1114 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1115 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1116 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1117 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1118 attributes.Add("type", "number"); 1119 1120 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1121 1122 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1123 @if (!string.IsNullOrEmpty(settings.Label)) 1124 { 1125 <label for="@settings.Id">@settings.Label</label> 1126 } 1127 @if (!string.IsNullOrEmpty(settings.HelpText)) 1128 { 1129 <small class="form__help-text">@settings.HelpText</small> 1130 } 1131 1132 @if (settings.ActionButton != null) 1133 { 1134 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1135 <div class="form__field-combi u-no-margin dw-mod"> 1136 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1137 @Render(settings.ActionButton) 1138 </div> 1139 } 1140 else 1141 { 1142 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1143 } 1144 1145 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1146 </div> 1147 } 1148 @using System.Reflection 1149 @using Dynamicweb.Rapido.Blocks.Components.General 1150 @using Dynamicweb.Rapido.Blocks.Components 1151 1152 1153 @* Component *@ 1154 1155 @helper RenderTextareaField(TextareaField settings) 1156 { 1157 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1158 string id = settings.Id; 1159 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1160 { 1161 id = Guid.NewGuid().ToString("N"); 1162 } 1163 1164 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1165 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1166 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1167 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1168 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1169 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1170 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1171 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1172 if (settings.Required) { attributes.Add("required", "true"); } 1173 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1174 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1175 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1176 attributes.Add("name", settings.Name); 1177 1178 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1179 @if (!string.IsNullOrEmpty(settings.Label)) 1180 { 1181 <label for="@id">@settings.Label</label> 1182 } 1183 @if (!string.IsNullOrEmpty(settings.HelpText)) 1184 { 1185 <small class="form__help-text">@settings.HelpText</small> 1186 } 1187 1188 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1189 1190 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1191 </div> 1192 } 1193 @using System.Reflection 1194 @using Dynamicweb.Rapido.Blocks.Components.General 1195 @using Dynamicweb.Rapido.Blocks.Components 1196 1197 1198 @* Component *@ 1199 1200 @helper RenderHiddenField(HiddenField settings) { 1201 var attributes = new Dictionary<string, string>(); 1202 attributes.Add("type", "hidden"); 1203 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1204 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1205 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1206 1207 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1208 } 1209 @using System.Reflection 1210 @using Dynamicweb.Rapido.Blocks.Components.General 1211 @using Dynamicweb.Rapido.Blocks.Components 1212 1213 @* Component *@ 1214 1215 @helper RenderCheckboxField(CheckboxField settings) 1216 { 1217 var attributes = new Dictionary<string, string>(); 1218 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1219 { 1220 settings.Id = Guid.NewGuid().ToString("N"); 1221 } 1222 1223 /*base settings*/ 1224 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1225 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1226 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1227 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1228 if (settings.Required) { attributes.Add("required", "true"); } 1229 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1230 /*end*/ 1231 1232 attributes.Add("type", "checkbox"); 1233 if (settings.Checked) { attributes.Add("checked", "true"); } 1234 settings.CssClass = "form__control " + settings.CssClass; 1235 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1236 1237 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1238 1239 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1240 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1241 @if (!string.IsNullOrEmpty(settings.Label)) 1242 { 1243 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1244 } 1245 @if (!string.IsNullOrEmpty(settings.HelpText)) 1246 { 1247 <small class="form__help-text">@settings.HelpText</small> 1248 } 1249 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1250 </div> 1251 } 1252 @using System.Reflection 1253 @using Dynamicweb.Rapido.Blocks.Components.General 1254 @using Dynamicweb.Rapido.Blocks.Components 1255 1256 1257 @* Component *@ 1258 1259 @helper RenderCheckboxListField(CheckboxListField settings) 1260 { 1261 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1262 @if (!string.IsNullOrEmpty(settings.Label)) 1263 { 1264 <label>@settings.Label</label> 1265 } 1266 @if (!string.IsNullOrEmpty(settings.HelpText)) 1267 { 1268 <small class="form__help-text">@settings.HelpText</small> 1269 } 1270 1271 @foreach (var item in settings.Options) 1272 { 1273 if (settings.Required) 1274 { 1275 item.Required = true; 1276 } 1277 if (settings.Disabled) 1278 { 1279 item.Disabled = true; 1280 } 1281 if (!string.IsNullOrEmpty(settings.Name)) 1282 { 1283 item.Name = settings.Name; 1284 } 1285 if (!string.IsNullOrEmpty(settings.CssClass)) 1286 { 1287 item.CssClass += settings.CssClass; 1288 } 1289 1290 /* value is not supported */ 1291 1292 if (!string.IsNullOrEmpty(settings.OnClick)) 1293 { 1294 item.OnClick += settings.OnClick; 1295 } 1296 if (!string.IsNullOrEmpty(settings.OnChange)) 1297 { 1298 item.OnChange += settings.OnChange; 1299 } 1300 @Render(item) 1301 } 1302 1303 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1304 </div> 1305 } 1306 @using System.Reflection 1307 @using Dynamicweb.Rapido.Blocks.Components.General 1308 @using Dynamicweb.Rapido.Blocks.Components 1309 1310 1311 @* Component *@ 1312 1313 @helper RenderSelectField(SelectField settings) 1314 { 1315 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1316 { 1317 settings.Id = Guid.NewGuid().ToString("N"); 1318 } 1319 1320 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1321 @if (!string.IsNullOrEmpty(settings.Label)) 1322 { 1323 <label for="@settings.Id">@settings.Label</label> 1324 } 1325 @if (!string.IsNullOrEmpty(settings.HelpText)) 1326 { 1327 <small class="form__help-text">@settings.HelpText</small> 1328 } 1329 1330 @if (settings.ActionButton != null) 1331 { 1332 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1333 <div class="form__field-combi u-no-margin dw-mod"> 1334 @RenderSelectBase(settings) 1335 @Render(settings.ActionButton) 1336 </div> 1337 } 1338 else 1339 { 1340 @RenderSelectBase(settings) 1341 } 1342 1343 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1344 </div> 1345 } 1346 1347 @helper RenderSelectBase(SelectField settings) 1348 { 1349 var attributes = new Dictionary<string, string>(); 1350 1351 /*base settings*/ 1352 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1353 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1354 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1355 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1356 if (settings.Required) { attributes.Add("required", "true"); } 1357 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1358 /*end*/ 1359 1360 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1361 1362 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1363 @if (settings.Default != null) 1364 { 1365 @Render(settings.Default) 1366 } 1367 1368 @foreach (var item in settings.Options) 1369 { 1370 if (!string.IsNullOrEmpty(settings.Value)) { 1371 item.Checked = item.Value == settings.Value; 1372 } 1373 @Render(item) 1374 } 1375 </select> 1376 } 1377 @using System.Reflection 1378 @using Dynamicweb.Rapido.Blocks.Components.General 1379 @using Dynamicweb.Rapido.Blocks.Components 1380 1381 @* Component *@ 1382 1383 @helper RenderRadioButtonField(RadioButtonField settings) 1384 { 1385 var attributes = new Dictionary<string, string>(); 1386 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1387 { 1388 settings.Id = Guid.NewGuid().ToString("N"); 1389 } 1390 1391 /*base settings*/ 1392 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1393 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1394 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1395 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1396 if (settings.Required) { attributes.Add("required", "true"); } 1397 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1398 /*end*/ 1399 1400 attributes.Add("type", "radio"); 1401 if (settings.Checked) { attributes.Add("checked", "true"); } 1402 settings.CssClass = "form__control " + settings.CssClass; 1403 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1404 1405 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1406 1407 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1408 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1409 @if (!string.IsNullOrEmpty(settings.Label)) 1410 { 1411 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1412 } 1413 @if (!string.IsNullOrEmpty(settings.HelpText)) 1414 { 1415 <small class="form__help-text">@settings.HelpText</small> 1416 } 1417 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1418 </div> 1419 } 1420 @using System.Reflection 1421 @using Dynamicweb.Rapido.Blocks.Components.General 1422 @using Dynamicweb.Rapido.Blocks.Components 1423 1424 1425 @* Component *@ 1426 1427 @helper RenderRadioButtonListField(RadioButtonListField settings) 1428 { 1429 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1430 @if (!string.IsNullOrEmpty(settings.Label)) 1431 { 1432 <label>@settings.Label</label> 1433 } 1434 @if (!string.IsNullOrEmpty(settings.HelpText)) 1435 { 1436 <small class="form__help-text">@settings.HelpText</small> 1437 } 1438 1439 @foreach (var item in settings.Options) 1440 { 1441 if (settings.Required) 1442 { 1443 item.Required = true; 1444 } 1445 if (settings.Disabled) 1446 { 1447 item.Disabled = true; 1448 } 1449 if (!string.IsNullOrEmpty(settings.Name)) 1450 { 1451 item.Name = settings.Name; 1452 } 1453 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1454 { 1455 item.Checked = true; 1456 } 1457 if (!string.IsNullOrEmpty(settings.OnClick)) 1458 { 1459 item.OnClick += settings.OnClick; 1460 } 1461 if (!string.IsNullOrEmpty(settings.OnChange)) 1462 { 1463 item.OnChange += settings.OnChange; 1464 } 1465 if (!string.IsNullOrEmpty(settings.CssClass)) 1466 { 1467 item.CssClass += settings.CssClass; 1468 } 1469 @Render(item) 1470 } 1471 1472 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1473 </div> 1474 } 1475 @using System.Reflection 1476 @using Dynamicweb.Rapido.Blocks.Components.General 1477 @using Dynamicweb.Rapido.Blocks.Components 1478 1479 1480 @* Component *@ 1481 1482 @helper RenderNotificationMessage(NotificationMessage settings) 1483 { 1484 if (!string.IsNullOrEmpty(settings.Message)) 1485 { 1486 var attributes = new Dictionary<string, string>(); 1487 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1488 1489 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1490 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1491 } 1492 } 1493 @using Dynamicweb.Rapido.Blocks.Components.General 1494 1495 1496 @* Component *@ 1497 1498 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1499 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1500 1501 <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> 1502 @if (settings.SubBlocks != null) { 1503 @RenderBlockList(settings.SubBlocks) 1504 } 1505 </div> 1506 } 1507 @using System.Reflection 1508 @using Dynamicweb.Rapido.Blocks.Components.General 1509 @using Dynamicweb.Rapido.Blocks.Components 1510 @using System.Text.RegularExpressions 1511 1512 1513 @* Component *@ 1514 1515 @helper RenderSticker(Sticker settings) { 1516 if (!String.IsNullOrEmpty(settings.Title)) { 1517 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1518 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1519 1520 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1521 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1522 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1523 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1524 optionalAttributes.Add("style", styleTag); 1525 } 1526 1527 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1528 } 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 RenderStickersCollection(StickersCollection settings) 1539 { 1540 if (settings.Stickers.Count > 0) 1541 { 1542 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1543 1544 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1545 @foreach (Sticker sticker in settings.Stickers) 1546 { 1547 @Render(sticker) 1548 } 1549 </div> 1550 } 1551 } 1552 1553 @using Dynamicweb.Rapido.Blocks.Components.General 1554 1555 1556 @* Component *@ 1557 1558 @helper RenderForm(Form settings) { 1559 if (settings != null) 1560 { 1561 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1562 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1563 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1564 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1565 var enctypes = new Dictionary<string, string> 1566 { 1567 { "multipart", "multipart/form-data" }, 1568 { "text", "text/plain" }, 1569 { "application", "application/x-www-form-urlencoded" } 1570 }; 1571 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1572 optionalAttributes.Add("method", settings.Method.ToString()); 1573 1574 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1575 { 1576 @settings.FormStartMarkup 1577 } 1578 else 1579 { 1580 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1581 } 1582 1583 foreach (var field in settings.GetFields()) 1584 { 1585 @Render(field) 1586 } 1587 1588 @:</form> 1589 } 1590 } 1591 @using System.Reflection 1592 @using Dynamicweb.Rapido.Blocks.Components.General 1593 @using Dynamicweb.Rapido.Blocks.Components 1594 1595 1596 @* Component *@ 1597 1598 @helper RenderText(Text settings) 1599 { 1600 @settings.Content 1601 } 1602 @using System.Reflection 1603 @using Dynamicweb.Rapido.Blocks.Components.General 1604 @using Dynamicweb.Rapido.Blocks.Components 1605 1606 1607 @* Component *@ 1608 1609 @helper RenderContentModule(ContentModule settings) { 1610 if (!string.IsNullOrEmpty(settings.Content)) 1611 { 1612 @settings.Content 1613 } 1614 } 1615 @using System.Reflection 1616 @using Dynamicweb.Rapido.Blocks.Components.General 1617 @using Dynamicweb.Rapido.Blocks.Components 1618 1619 1620 @* Component *@ 1621 1622 @helper RenderModal(Modal settings) { 1623 if (settings != null) 1624 { 1625 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1626 1627 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1628 1629 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1630 1631 <div class="modal-container"> 1632 @if (!settings.DisableDarkOverlay) 1633 { 1634 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1635 } 1636 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1637 @if (settings.Heading != null) 1638 { 1639 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1640 { 1641 <div class="modal__header"> 1642 @Render(settings.Heading) 1643 </div> 1644 } 1645 } 1646 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1647 @if (!string.IsNullOrEmpty(settings.BodyText)) 1648 { 1649 @settings.BodyText 1650 } 1651 @if (settings.BodyTemplate != null) 1652 { 1653 @settings.BodyTemplate 1654 } 1655 @{ 1656 var actions = settings.GetActions(); 1657 } 1658 </div> 1659 @if (actions.Length > 0) 1660 { 1661 <div class="modal__footer"> 1662 @foreach (var action in actions) 1663 { 1664 action.CssClass += " u-no-margin"; 1665 @Render(action) 1666 } 1667 </div> 1668 } 1669 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1670 </div> 1671 </div> 1672 } 1673 } 1674 @using Dynamicweb.Rapido.Blocks.Components.General 1675 1676 @* Component *@ 1677 1678 @helper RenderMediaListItem(MediaListItem settings) 1679 { 1680 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1681 @if (!string.IsNullOrEmpty(settings.Label)) 1682 { 1683 if (!string.IsNullOrEmpty(settings.Link)) 1684 { 1685 @Render(new Link 1686 { 1687 Href = settings.Link, 1688 CssClass = "media-list-item__sticker dw-mod", 1689 ButtonLayout = ButtonLayout.None, 1690 Title = settings.Label, 1691 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1692 }) 1693 } 1694 else if (!string.IsNullOrEmpty(settings.OnClick)) 1695 { 1696 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1697 <span class="u-uppercase">@settings.Label</span> 1698 </span> 1699 } 1700 else 1701 { 1702 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1703 <span class="u-uppercase">@settings.Label</span> 1704 </span> 1705 } 1706 } 1707 <div class="media-list-item__wrap"> 1708 <div class="media-list-item__info dw-mod"> 1709 <div class="media-list-item__header dw-mod"> 1710 @if (!string.IsNullOrEmpty(settings.Title)) 1711 { 1712 if (!string.IsNullOrEmpty(settings.Link)) 1713 { 1714 @Render(new Link 1715 { 1716 Href = settings.Link, 1717 CssClass = "media-list-item__name dw-mod", 1718 ButtonLayout = ButtonLayout.None, 1719 Title = settings.Title, 1720 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1721 }) 1722 } 1723 else if (!string.IsNullOrEmpty(settings.OnClick)) 1724 { 1725 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1726 } 1727 else 1728 { 1729 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1730 } 1731 } 1732 1733 @if (!string.IsNullOrEmpty(settings.Status)) 1734 { 1735 <div class="media-list-item__state dw-mod">@settings.Status</div> 1736 } 1737 </div> 1738 @{ 1739 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1740 } 1741 1742 @Render(settings.InfoTable) 1743 </div> 1744 <div class="media-list-item__actions dw-mod"> 1745 <div class="media-list-item__actions-list dw-mod"> 1746 @{ 1747 var actions = settings.GetActions(); 1748 1749 foreach (ButtonBase action in actions) 1750 { 1751 action.ButtonLayout = ButtonLayout.None; 1752 action.CssClass += " media-list-item__action link"; 1753 1754 @Render(action) 1755 } 1756 } 1757 </div> 1758 1759 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1760 { 1761 settings.SelectButton.CssClass += " u-no-margin"; 1762 1763 <div class="media-list-item__action-button"> 1764 @Render(settings.SelectButton) 1765 </div> 1766 } 1767 </div> 1768 </div> 1769 </div> 1770 } 1771 @using Dynamicweb.Rapido.Blocks.Components.General 1772 @using Dynamicweb.Rapido.Blocks.Components 1773 1774 @helper RenderTable(Table settings) 1775 { 1776 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1777 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1778 1779 var enumToClasses = new Dictionary<TableDesign, string> 1780 { 1781 { TableDesign.Clean, "table--clean" }, 1782 { TableDesign.Bordered, "table--bordered" }, 1783 { TableDesign.Striped, "table--striped" }, 1784 { TableDesign.Hover, "table--hover" }, 1785 { TableDesign.Compact, "table--compact" }, 1786 { TableDesign.Condensed, "table--condensed" }, 1787 { TableDesign.NoTopBorder, "table--no-top-border" } 1788 }; 1789 string tableDesignClass = ""; 1790 if (settings.Design != TableDesign.None) 1791 { 1792 tableDesignClass = enumToClasses[settings.Design]; 1793 } 1794 1795 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1796 1797 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1798 1799 <table @ComponentMethods.AddAttributes(resultAttributes)> 1800 @if (settings.Header != null) 1801 { 1802 <thead> 1803 @Render(settings.Header) 1804 </thead> 1805 } 1806 <tbody> 1807 @foreach (var row in settings.Rows) 1808 { 1809 @Render(row) 1810 } 1811 </tbody> 1812 @if (settings.Footer != null) 1813 { 1814 <tfoot> 1815 @Render(settings.Footer) 1816 </tfoot> 1817 } 1818 </table> 1819 } 1820 @using Dynamicweb.Rapido.Blocks.Components.General 1821 @using Dynamicweb.Rapido.Blocks.Components 1822 1823 @helper RenderTableRow(TableRow settings) 1824 { 1825 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1826 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1827 1828 var enumToClasses = new Dictionary<TableRowDesign, string> 1829 { 1830 { TableRowDesign.NoBorder, "table__row--no-border" }, 1831 { TableRowDesign.Border, "table__row--border" }, 1832 { TableRowDesign.TopBorder, "table__row--top-line" }, 1833 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1834 { TableRowDesign.Solid, "table__row--solid" } 1835 }; 1836 1837 string tableRowDesignClass = ""; 1838 if (settings.Design != TableRowDesign.None) 1839 { 1840 tableRowDesignClass = enumToClasses[settings.Design]; 1841 } 1842 1843 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1844 1845 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1846 1847 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1848 @foreach (var cell in settings.Cells) 1849 { 1850 if (settings.IsHeaderRow) 1851 { 1852 cell.IsHeader = true; 1853 } 1854 @Render(cell) 1855 } 1856 </tr> 1857 } 1858 @using Dynamicweb.Rapido.Blocks.Components.General 1859 @using Dynamicweb.Rapido.Blocks.Components 1860 @using Dynamicweb.Core 1861 1862 @helper RenderTableCell(TableCell settings) 1863 { 1864 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1865 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1866 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1867 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1868 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1869 1870 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1871 1872 string tagName = settings.IsHeader ? "th" : "td"; 1873 1874 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 1875 @settings.Content 1876 @("</" + tagName + ">"); 1877 } 1878 @using System.Linq 1879 @using Dynamicweb.Rapido.Blocks.Components.General 1880 1881 @* Component *@ 1882 1883 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1884 { 1885 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1886 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1887 1888 if (settings.NumberOfPages > 1) 1889 { 1890 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1891 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 1892 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1893 1894 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1895 @if (settings.ShowPagingInfo) 1896 { 1897 <div class="pager__info dw-mod"> 1898 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1899 </div> 1900 } 1901 <ul class="pager__list dw-mod"> 1902 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1903 { 1904 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1905 } 1906 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1907 { 1908 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 1909 } 1910 @if (settings.GetPages().Any()) 1911 { 1912 foreach (var page in settings.GetPages()) 1913 { 1914 @Render(page) 1915 } 1916 } 1917 else 1918 { 1919 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1920 { 1921 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1922 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1923 } 1924 } 1925 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1926 { 1927 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 1928 } 1929 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1930 { 1931 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1932 } 1933 </ul> 1934 </div> 1935 } 1936 } 1937 1938 @helper RenderPaginationItem(PaginationItem settings) 1939 { 1940 if (settings.Icon == null) 1941 { 1942 settings.Icon = new Icon(); 1943 } 1944 1945 settings.Icon.Label = settings.Label; 1946 <li class="pager__btn dw-mod"> 1947 @if (settings.IsActive) 1948 { 1949 <span class="pager__num pager__num--current dw-mod"> 1950 @Render(settings.Icon) 1951 </span> 1952 } 1953 else 1954 { 1955 <a href="@settings.Link" class="pager__num dw-mod"> 1956 @Render(settings.Icon) 1957 </a> 1958 } 1959 </li> 1960 } 1961 1962 1963 @using Dynamicweb.Rapido.Blocks.Components.General 1964 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 1965 1966 1967 @using Dynamicweb.Frontend 1968 @using System.Reflection 1969 @using Dynamicweb.Content.Items 1970 @using System.Web.UI.HtmlControls 1971 @using Dynamicweb.Rapido.Blocks.Components 1972 @using Dynamicweb.Rapido.Blocks 1973 @using Dynamicweb.Rapido.Blocks.Components.Articles 1974 1975 @* Components for the articles *@ 1976 @using System.Reflection 1977 @using Dynamicweb.Rapido.Blocks.Components.Articles 1978 1979 1980 @* Component for the articles *@ 1981 1982 @helper RenderArticleBanner(dynamic settings) { 1983 string filterClasses = "image-filter image-filter--darken"; 1984 settings.Layout = ArticleHeaderLayout.Banner; 1985 1986 if (settings.Image != null) 1987 { 1988 if (settings.Image.Path != null) 1989 { 1990 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width"> 1991 <div class="background-image @filterClasses dw-mod"> 1992 <div class="background-image__wrapper @filterClasses dw-mod"> 1993 @{ 1994 settings.Image.CssClass += "background-image__cover dw-mod"; 1995 } 1996 @Render(settings.Image) 1997 </div> 1998 </div> 1999 <div class="center-container dw-mod"> 2000 <div class="grid"> 2001 <div class="grid__col-md-8 grid__col-xs-12 paragraph-container paragraph-container--height-lg"> 2002 <div class="u-left-middle"> 2003 <div> 2004 @if (!String.IsNullOrEmpty(settings.Heading)) 2005 { 2006 <h1 class="article__header article__header--giant dw-mod" style="color: @settings.TextColor">@settings.Heading</h1> 2007 } 2008 @if (!String.IsNullOrEmpty(settings.Subheading)) 2009 { 2010 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div> 2011 } 2012 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2013 { 2014 <small class="article__post-info u-margin-bottom--lg dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small> 2015 } 2016 @if (!String.IsNullOrEmpty(settings.Link)) { 2017 <div class="grid__cell"> 2018 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2019 </div> 2020 } 2021 </div> 2022 </div> 2023 </div> 2024 @if (settings.ExternalParagraphId != 0) 2025 { 2026 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod"> 2027 <div class="u-color-light-gray--bg u-color-dark dw-mod"> 2028 @RenderParagraphContent(settings.ExternalParagraphId) 2029 </div> 2030 </div> 2031 } 2032 2033 </div> 2034 </div> 2035 </section> 2036 if (!String.IsNullOrEmpty(settings.Image.Caption)) { 2037 <div class="image-caption dw-mod">@settings.Image.Caption</div> 2038 } 2039 } 2040 else 2041 { 2042 settings.Layout = ArticleHeaderLayout.Clean; 2043 @RenderArticleCleanHeader(settings); 2044 } 2045 } 2046 else 2047 { 2048 settings.Layout = ArticleHeaderLayout.Clean; 2049 @RenderArticleCleanHeader(settings); 2050 } 2051 } 2052 @using System.Reflection 2053 @using Dynamicweb.Rapido.Blocks.Components 2054 @using Dynamicweb.Rapido.Blocks.Components.General 2055 @using Dynamicweb.Rapido.Blocks.Components.Articles 2056 @using Dynamicweb.Rapido.Blocks 2057 2058 2059 @* Component for the articles *@ 2060 2061 @helper RenderArticleHeader(ArticleHeader settings) { 2062 dynamic[] methodParameters = new dynamic[1]; 2063 methodParameters[0] = settings; 2064 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleHeaderCustom"); 2065 2066 if (customMethod != null) 2067 { 2068 @customMethod.Invoke(this, methodParameters).ToString(); 2069 } else { 2070 switch (settings.Layout) 2071 { 2072 case ArticleHeaderLayout.Clean: 2073 @RenderArticleCleanHeader(settings); 2074 break; 2075 case ArticleHeaderLayout.Split: 2076 @RenderArticleSplitHeader(settings); 2077 break; 2078 case ArticleHeaderLayout.Banner: 2079 @RenderArticleBannerHeader(settings); 2080 break; 2081 case ArticleHeaderLayout.Overlay: 2082 @RenderArticleOverlayHeader(settings); 2083 break; 2084 default: 2085 @RenderArticleCleanHeader(settings); 2086 break; 2087 } 2088 } 2089 } 2090 2091 @helper RenderArticleCleanHeader(ArticleHeader settings) { 2092 dynamic[] methodParameters = new dynamic[1]; 2093 methodParameters[0] = settings; 2094 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleCleanHeaderCustom"); 2095 2096 if (customMethod != null) 2097 { 2098 @customMethod.Invoke(this, methodParameters).ToString(); 2099 } 2100 else 2101 { 2102 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12"; 2103 2104 <div class="grid grid--align-content-start grid--justify-start"> 2105 <div class="grid__col-md-@contentColumns grid__col-sm-12 u-padding--lg dw-mod"> 2106 @if (!String.IsNullOrEmpty(settings.Category) || !String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date) || settings.RatingOutOf != 0) 2107 { 2108 <div class="u-border-bottom u-padding-bottom"> 2109 @if (!String.IsNullOrEmpty(settings.Category)) 2110 { 2111 <div class="u-pull--left"> 2112 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div> 2113 </div> 2114 } 2115 <div class="u-pull--right"> 2116 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2117 { 2118 <small class="article__post-info dw-mod">@settings.Author @settings.Date</small> 2119 } 2120 @if (settings.RatingOutOf != 0) 2121 { 2122 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2123 } 2124 </div> 2125 </div> 2126 } 2127 2128 <div class="grid__cell"> 2129 @if (!String.IsNullOrEmpty(settings.Heading)) 2130 { 2131 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1> 2132 } 2133 @if (settings.Image != null) 2134 { 2135 if (settings.Image.Path != null) 2136 { 2137 <div class="u-padding-bottom--lg"> 2138 @Render(settings.Image) 2139 </div> 2140 } 2141 } 2142 @if (!String.IsNullOrEmpty(settings.Subheading)) 2143 { 2144 <div class="article__leadtext dw-mod">@settings.Subheading</div> 2145 } 2146 @if (!String.IsNullOrEmpty(settings.Link)) 2147 { 2148 <div class="grid__cell"> 2149 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2150 </div> 2151 } 2152 </div> 2153 </div> 2154 @if (settings.ExternalParagraphId != 0) 2155 { 2156 <div class="grid__col-md-4 grid__col-sm-12 u-padding--lg u-color-light-gray--bg dw-mod"> 2157 @RenderParagraphContent(settings.ExternalParagraphId) 2158 </div> 2159 } 2160 </div> 2161 } 2162 } 2163 2164 @helper RenderArticleSplitHeader(ArticleHeader settings) { 2165 dynamic[] methodParameters = new dynamic[1]; 2166 methodParameters[0] = settings; 2167 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleSplitHeaderCustom"); 2168 2169 if (customMethod != null) 2170 { 2171 @customMethod.Invoke(this, methodParameters).ToString(); 2172 } 2173 else 2174 { 2175 string headerColumnWidth = settings.ExternalParagraphId != 0 ? "4" : "6"; 2176 2177 if (settings.Image != null) 2178 { 2179 if (settings.Image.Path != null) 2180 { 2181 <section class="multiple-paragraphs-container paragraph-container--full-width"> 2182 <div class="grid"> 2183 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-xl dw-mod"> 2184 <div class="u-left-middle u-padding--lg"> 2185 <div> 2186 @if (!String.IsNullOrEmpty(settings.Category)) 2187 { 2188 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div> 2189 } 2190 @if (!String.IsNullOrEmpty(settings.Heading)) 2191 { 2192 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1> 2193 } 2194 @if (!String.IsNullOrEmpty(settings.Subheading)) 2195 { 2196 <div class="article__leadtext dw-mod">@settings.Subheading</div> 2197 } 2198 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2199 { 2200 <small class="article__post-info u-pull--left dw-mod">@settings.Author @settings.Date</small> 2201 } 2202 @if (settings.RatingOutOf != 0) 2203 { 2204 <div class="u-pull--right"> 2205 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2206 </div> 2207 } 2208 @if (!String.IsNullOrEmpty(settings.Link)) { 2209 <div class="u-full-width u-pull--left u-margin-top"> 2210 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2211 </div> 2212 } 2213 </div> 2214 </div> 2215 </div> 2216 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod" style="background-image:url(/Admin/Public/GetImage.ashx?width=1800&amp;height=1100&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=@settings.Image.Path); background-position: center center; background-size: cover;"></div> 2217 @if (settings.ExternalParagraphId != 0) 2218 { 2219 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto u-color-light-gray--bg dw-mod"> 2220 @RenderParagraphContent(settings.ExternalParagraphId) 2221 </div> 2222 } 2223 </div> 2224 </section> 2225 } 2226 } 2227 else 2228 { 2229 @RenderArticleCleanHeader(settings); 2230 } 2231 } 2232 } 2233 2234 @helper RenderArticleOverlayHeader(ArticleHeader settings) { 2235 dynamic[] methodParameters = new dynamic[1]; 2236 methodParameters[0] = settings; 2237 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleOverlayHeaderCustom"); 2238 2239 if (customMethod != null) 2240 { 2241 @customMethod.Invoke(this, methodParameters).ToString(); 2242 } 2243 else 2244 { 2245 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12"; 2246 string contentAlignment = settings.TextLayout == ArticleHeaderTextLayout.Center ? "grid--justify-center" : ""; 2247 2248 if (settings.Image != null) 2249 { 2250 if (settings.Image.Path != null) 2251 { 2252 if (settings.ExternalParagraphId == 0) 2253 { 2254 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width"> 2255 <div class="background-image image-filter image-filter--darken dw-mod"> 2256 <div class="background-image__wrapper image-filter image-filter--darken dw-mod"> 2257 @{ 2258 settings.Image.CssClass += "background-image__cover dw-mod"; 2259 } 2260 @Render(settings.Image) 2261 </div> 2262 </div> 2263 <div class="center-container dw-mod"> 2264 <div class="grid @contentAlignment"> 2265 <div class="grid__col-md-@contentColumns grid__col-xs-12 paragraph-container paragraph-container--height-xl u-no-padding dw-mod"> 2266 @if (!String.IsNullOrEmpty(settings.Heading)) 2267 { 2268 <h1 class="article__header article__header--giant u-padding-top--lg dw-mod" style="color: @settings.TextColor">@settings.Heading</h1> 2269 } 2270 @if (!String.IsNullOrEmpty(settings.Subheading)) 2271 { 2272 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div> 2273 } 2274 <div class="u-margin-top"> 2275 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2276 { 2277 <small class="article__post-info u-pull--left dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small> 2278 } 2279 @if (settings.RatingOutOf != 0) 2280 { 2281 <div class="u-pull--right"> 2282 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2283 </div> 2284 } 2285 </div> 2286 @if (!String.IsNullOrEmpty(settings.Link)) 2287 { 2288 <div class="grid__cell"> 2289 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2290 </div> 2291 } 2292 </div> 2293 </div> 2294 </div> 2295 </section> 2296 } 2297 else 2298 { 2299 @RenderArticleBanner(settings); 2300 } 2301 } 2302 } 2303 else 2304 { 2305 @RenderArticleCleanHeader(settings); 2306 } 2307 } 2308 } 2309 2310 @helper RenderArticleBannerHeader(dynamic settings) { 2311 dynamic[] methodParameters = new dynamic[1]; 2312 methodParameters[0] = settings; 2313 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleBannerHeaderCustom"); 2314 2315 if (customMethod != null) 2316 { 2317 @customMethod.Invoke(this, methodParameters).ToString(); 2318 } 2319 else 2320 { 2321 @RenderArticleBanner(settings); 2322 } 2323 } 2324 @using System.Reflection 2325 @using System.Text.RegularExpressions; 2326 @using Dynamicweb.Frontend 2327 @using Dynamicweb.Content.Items 2328 @using Dynamicweb.Rapido.Blocks.Components 2329 @using Dynamicweb.Rapido.Blocks.Components.Articles 2330 @using Dynamicweb.Rapido.Blocks 2331 2332 @* Component for the articles *@ 2333 2334 @helper RenderArticleBodyRow(ArticleBodyRow settings) 2335 { 2336 string position = settings.TopLayout == "overlay" ? "article__overlay-offset" : ""; 2337 string contentAlignment = settings.TextLayout == "center" ? "grid--justify-center" : ""; 2338 2339 <div class="grid grid--align-content-start @contentAlignment @position dw-mod"> 2340 @RenderBlockList(settings.SubBlocks) 2341 </div> 2342 } 2343 @using System.Reflection 2344 @using Dynamicweb.Rapido.Blocks.Components 2345 @using Dynamicweb.Rapido.Blocks.Components.General 2346 @using Dynamicweb.Rapido.Blocks.Components.Articles 2347 @using Dynamicweb.Rapido.Blocks 2348 2349 @* Component for the articles *@ 2350 2351 @helper RenderArticleImage(ArticleImage settings) 2352 { 2353 if (settings.Image != null) 2354 { 2355 if (settings.Image.Path != null) 2356 { 2357 <div class="u-margin-bottom--lg"> 2358 @Render(settings.Image) 2359 </div> 2360 } 2361 } 2362 } 2363 @using System.Reflection 2364 @using Dynamicweb.Rapido.Blocks.Components 2365 @using Dynamicweb.Rapido.Blocks.Components.Articles 2366 2367 2368 @* Component for the articles *@ 2369 2370 @helper RenderArticleSubHeader(ArticleSubHeader settings) 2371 { 2372 if (!String.IsNullOrEmpty(settings.Title)) 2373 { 2374 <h2 class="article__header">@settings.Title</h2> 2375 } 2376 } 2377 @using System.Reflection 2378 @using Dynamicweb.Rapido.Blocks.Components 2379 @using Dynamicweb.Rapido.Blocks.Components.Articles 2380 @using Dynamicweb.Rapido.Blocks 2381 2382 2383 @* Component for the articles *@ 2384 2385 @helper RenderArticleText(ArticleText settings) 2386 { 2387 if (!String.IsNullOrEmpty(settings.Text)) 2388 { 2389 string greatTextClass = settings.EnableLargeText == true ? "article__paragraph--great-text" : ""; 2390 2391 <div class="article__paragraph @greatTextClass"> 2392 @settings.Text 2393 </div> 2394 } 2395 } 2396 @using System.Reflection 2397 @using Dynamicweb.Rapido.Blocks.Components 2398 @using Dynamicweb.Rapido.Blocks.Components.Articles 2399 @using Dynamicweb.Rapido.Blocks 2400 2401 2402 @* Component for the articles *@ 2403 2404 @helper RenderArticleQuote(ArticleQuote settings) 2405 { 2406 string text = Regex.Replace(settings.Text, "<.*?>", String.Empty); 2407 2408 <div class="grid u-padding-bottom--lg"> 2409 @if (settings.Image != null) 2410 { 2411 if (settings.Image.Path != null) { 2412 <div class="grid__col-3"> 2413 <div class="grid__cell-img"> 2414 @{ 2415 settings.Image.Title = !String.IsNullOrEmpty(settings.Image.Title) ? settings.Image.Title : settings.Author; 2416 settings.Image.CssClass += " article__image article__image--ball"; 2417 settings.Image.ImageDefault.Width = 200; 2418 settings.Image.ImageDefault.Height = 200; 2419 } 2420 @Render(settings.Image) 2421 </div> 2422 </div> 2423 } 2424 } 2425 <div class="grid__col-auto"> 2426 @if (!String.IsNullOrEmpty(settings.Text)) 2427 { 2428 <div class="article__quote dw-mod"> 2429 <i class="fas fa-quote-right u-margin-bottom--lg"></i> 2430 @settings.Text 2431 <i class="fas fa-quote-right"></i> 2432 </div> 2433 } 2434 @if (!String.IsNullOrEmpty(settings.Author)) 2435 { 2436 <div class="article__quote-author dw-mod"> 2437 - @settings.Author 2438 </div> 2439 } 2440 </div> 2441 </div> 2442 } 2443 @using System.Reflection 2444 @using Dynamicweb.Rapido.Blocks.Components 2445 @using Dynamicweb.Rapido.Blocks.Components.Articles 2446 @using Dynamicweb.Rapido.Blocks 2447 2448 @* Component for the articles *@ 2449 2450 @helper RenderArticleInfoTable(ArticleInfoTable settings) 2451 { 2452 <table class="table table--clean"> 2453 @foreach (var row in settings.Rows) 2454 { 2455 string iconColor = row.IconColor != null ? row.IconColor : "u-brand-color-two"; 2456 2457 <tr> 2458 @if (!String.IsNullOrEmpty(row.Icon)) 2459 { 2460 <td class="u-w32px"><i class="@row.Icon fa-2x @row.IconColor"></i></td> 2461 } 2462 <td class="u-no-margin-on-p-elements"> 2463 <div class="u-bold">@row.Title</div> 2464 @if (!String.IsNullOrEmpty(row.SubTitle)) 2465 { 2466 if (row.Link == null) 2467 { 2468 <div>@row.SubTitle</div> 2469 } 2470 else 2471 { 2472 <a href="@row.Link" class="u-color-inherit">@row.SubTitle</a> 2473 } 2474 } 2475 </td> 2476 </tr> 2477 } 2478 </table> 2479 } 2480 @using System.Reflection 2481 @using Dynamicweb.Rapido.Blocks.Components 2482 @using Dynamicweb.Rapido.Blocks.Components.General 2483 @using Dynamicweb.Rapido.Blocks.Components.Articles 2484 @using Dynamicweb.Rapido.Blocks 2485 2486 @* Component for the articles *@ 2487 2488 @helper RenderArticleGalleryModal(ArticleGalleryModal settings) 2489 { 2490 Modal galleryModal = new Modal 2491 { 2492 Id = "ParagraphGallery", 2493 Width = ModalWidth.Full, 2494 BodyTemplate = RenderArticleGalleryModalContent() 2495 }; 2496 2497 @Render(galleryModal) 2498 } 2499 2500 @helper RenderArticleGalleryModalContent() { 2501 <div class="modal__image-min-size-wrapper"> 2502 @Render(new Image { 2503 Id = "ParagraphGallery", 2504 Path = "#", 2505 CssClass = "modal--full__img", 2506 DisableLazyLoad = true, 2507 DisableImageEngine = true 2508 }) 2509 </div> 2510 2511 <div class="modal__images-counter" id="ParagraphGallery_counter"></div> 2512 2513 @Render(new Button { 2514 Id = "ParagraphGallery_prev", 2515 ButtonType = ButtonType.Button, 2516 ButtonLayout = ButtonLayout.None, 2517 CssClass = "modal__prev-btn", 2518 Icon = new Icon { Prefix = "far", Name = "fa-angle-left", LabelPosition = IconLabelPosition.After }, 2519 OnClick = "Gallery.prevImage('ParagraphGallery')" 2520 }) 2521 2522 @Render(new Button { 2523 Id = "ParagraphGallery_next", 2524 ButtonType = ButtonType.Button, 2525 ButtonLayout = ButtonLayout.None, 2526 CssClass = "modal__next-btn", 2527 Icon = new Icon { Prefix = "far", Name = "fa-angle-right", LabelPosition = IconLabelPosition.After }, 2528 OnClick = "Gallery.nextImage('ParagraphGallery')" 2529 }) 2530 } 2531 @using System.Reflection 2532 @using Dynamicweb.Rapido.Blocks.Components 2533 @using Dynamicweb.Rapido.Blocks.Components.Articles 2534 @using Dynamicweb.Rapido.Blocks 2535 2536 2537 @* Component for the articles *@ 2538 2539 @helper RenderArticleRelated(ArticleRelated settings) 2540 { 2541 string cardClass = Pageview.Device.ToString() != "Tablet" ? "card u-color-light--bg u-full-height" : ""; 2542 string cardFooterClass = Pageview.Device.ToString() != "Tablet" ? "card-footer u-color-light--bg" : ""; 2543 2544 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width"> 2545 <div class="center-container dw-mod"> 2546 <div class="grid u-padding"> 2547 <div class="grid__col-md-12 grid__col-xs-12"> 2548 <h2 class="article__header u-no-margin u-margin-top">@settings.Title</h2> 2549 </div> 2550 </div> 2551 2552 <div class="js-handlebars-root u-padding" id="@settings.Title.Replace(" ", String.Empty)" data-template="RelatedSimpleTemplate" data-json-feed="/Default.aspx?ID=@settings.FeedPageId&@settings.Query&ExcludeItemID=@settings.CurrentPageId&PageSize=@settings.PageSize"></div> 2553 2554 <script id="RelatedSimpleTemplate" type="text/x-template"> 2555 {{#.}} 2556 <div class="grid u-padding-bottom--lg"> 2557 {{#Cases}} 2558 <div class="grid__col-3 image-hover--zoom dw-mod"> 2559 <a href="{{link}}" class="u-full-height u-color-light--bg"> 2560 {{#if image}} 2561 <div class="u-color-light--bg u-no-padding dw-mod"> 2562 <div class="flex-img image-hover__wrapper"> 2563 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=680&height=314&amp;crop=1&amp;DoNotUpscale=True&amp;Compression=75&amp;image={{image}}" alt="{{title}}" /> 2564 </div> 2565 </div> 2566 {{/if}} 2567 2568 <div class="card u-color-light--bg dw-mod"> 2569 <h3 class="article-list__item-header u-truncate-text dw-mod">{{title}}</h3> 2570 <p class="article__short-summary dw-mod">{{summary}}</p> 2571 </div> 2572 </a> 2573 </div> 2574 {{/Cases}} 2575 </div> 2576 {{/.}} 2577 </script> 2578 </div> 2579 </section> 2580 } 2581 @using System.Reflection 2582 @using Dynamicweb.Rapido.Blocks.Components 2583 @using Dynamicweb.Rapido.Blocks.Components.Articles 2584 @using Dynamicweb.Rapido.Blocks 2585 2586 2587 @* Component for the articles *@ 2588 2589 @helper RenderArticleMenu(ArticleMenu settings) 2590 { 2591 if (!String.IsNullOrEmpty(settings.Title)) { 2592 <div class="u-margin u-border-bottom"> 2593 <h3 class="u-no-margin">@settings.Title</h3> 2594 </div> 2595 } 2596 2597 <ul class="menu-left u-margin-bottom dw-mod"> 2598 @foreach (var item in settings.Items) 2599 { 2600 @Render(item) 2601 } 2602 </ul> 2603 } 2604 2605 @helper RenderArticleMenuItem(ArticleMenuItem settings) 2606 { 2607 string link = !String.IsNullOrEmpty(settings.Link) ? settings.Link : "#"; 2608 2609 if (!String.IsNullOrEmpty(settings.Title)) { 2610 <li class="menu-left__item dw-mod"> 2611 <a href="@link" onclick="@settings.OnClick" class="menu-left__link dw-mod">@settings.Title</a> 2612 </li> 2613 } 2614 } 2615 @using System.Reflection 2616 @using Dynamicweb.Rapido.Blocks.Components 2617 @using Dynamicweb.Rapido.Blocks.Components.Articles 2618 @using Dynamicweb.Rapido.Blocks 2619 2620 @* Component for the articles *@ 2621 2622 @helper RenderArticleList(ArticleList settings) 2623 { 2624 if (Pageview != null) 2625 { 2626 bool isParagraph = Pageview.CurrentParagraph != null ? true : false; 2627 string[] sortArticlesListBy = new string[2]; 2628 2629 if (isParagraph) { 2630 sortArticlesListBy = Pageview.CurrentParagraph.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString()) ? Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" }; 2631 } 2632 else { 2633 sortArticlesListBy = Pageview.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.Item["SortArticlesListBy"].ToString()) ? Pageview.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" }; 2634 } 2635 2636 string sourcePage = settings.SourcePage != null ? settings.SourcePage : Pageview.ID.ToString(); 2637 2638 if (!settings.DisablePagination) { 2639 @RenderItemList(new 2640 { 2641 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle", 2642 ListSourceType = settings.SourceType, 2643 ListSourcePage = sourcePage, 2644 ItemFieldsList = "*", 2645 Filter = settings.Filter, 2646 ListOrderBy = sortArticlesListBy[0], 2647 ListOrderByDirection = sortArticlesListBy[1], 2648 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date", 2649 ListSecondOrderByDirection = "ASC", 2650 IncludeAllChildItems = true, 2651 ListTemplate = settings.Template, 2652 ListPageSize = settings.PageSize.ToString() 2653 }); 2654 } else { 2655 @RenderItemList(new 2656 { 2657 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle", 2658 ListSourceType = settings.SourceType, 2659 ListSourcePage = sourcePage, 2660 ItemFieldsList = "*", 2661 Filter = settings.Filter, 2662 ListOrderBy = sortArticlesListBy[0], 2663 ListOrderByDirection = sortArticlesListBy[1], 2664 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date", 2665 ListSecondOrderByDirection = "ASC", 2666 IncludeAllChildItems = true, 2667 ListTemplate = settings.Template, 2668 ListPageSize = settings.PageSize.ToString(), 2669 ListViewMode = "Partial", 2670 ListShowTo = settings.PageSize + 1 2671 }); 2672 } 2673 } 2674 } 2675 @using System.Reflection 2676 @using Dynamicweb.Rapido.Blocks.Components.Articles 2677 2678 2679 @* Component for the articles *@ 2680 2681 @helper RenderArticleSummary(ArticleSummary settings) 2682 { 2683 if (!String.IsNullOrEmpty(settings.Text)) 2684 { 2685 <div class="article__summary dw-mod">@settings.Text</div> 2686 } 2687 } 2688 @using System.Reflection 2689 @using Dynamicweb.Rapido.Blocks.Components 2690 @using Dynamicweb.Rapido.Blocks.Components.Articles 2691 @using Dynamicweb.Rapido.Blocks 2692 2693 @* Component for the articles *@ 2694 2695 @helper RenderArticleListCategoryFilter(ArticleListCategoryFilter settings) 2696 { 2697 string pageId = Pageview.ID.ToString(); 2698 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("sourcePage")) ? HttpContext.Current.Request.QueryString.Get("sourcePage") : Translate("All"); 2699 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString()); 2700 2701 foreach (var option in settings.Categories) 2702 { 2703 selectedFilter = selectedFilter == option.Value ? option.Key : selectedFilter; 2704 } 2705 2706 if (selectedFilter == pageId) 2707 { 2708 selectedFilter = Translate("All"); 2709 } 2710 2711 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 2712 { 2713 <div class="u-pull--right u-margin-left"> 2714 <div class="collection u-no-margin"> 2715 <h5>@Translate("Category")</h5> 2716 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" /> 2717 <div class="dropdown u-w180px dw-mod"> 2718 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label> 2719 <div class="dropdown__content dw-mod"> 2720 @foreach (var option in settings.Categories) 2721 { 2722 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div> 2723 } 2724 </div> 2725 <label class="dropdown-trigger-off" for="CategorySelector"></label> 2726 </div> 2727 </div> 2728 </div> 2729 } 2730 else 2731 { 2732 <div class="u-full-width u-margin-bottom"> 2733 <h5 class="u-no-margin">@Translate("Category")</h5> 2734 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" /> 2735 <div class="dropdown u-full-width dw-mod"> 2736 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label> 2737 <div class="dropdown__content dw-mod"> 2738 @foreach (var option in settings.Categories) 2739 { 2740 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div> 2741 } 2742 </div> 2743 <label class="dropdown-trigger-off" for="CategorySelector"></label> 2744 </div> 2745 </div> 2746 } 2747 } 2748 @using System.Reflection 2749 @using Dynamicweb.Rapido.Blocks.Components 2750 @using Dynamicweb.Rapido.Blocks.Components.Articles 2751 @using Dynamicweb.Rapido.Blocks 2752 @using System.Collections.Generic 2753 2754 @* Component for the articles *@ 2755 2756 @helper RenderArticleListFilter(ArticleListFilter settings) 2757 { 2758 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get(settings.SystemName)) ? HttpContext.Current.Request.QueryString.Get(settings.SystemName) : Translate("All"); 2759 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString()); 2760 2761 if (settings.Options != null) 2762 { 2763 if (settings.Options is IEnumerable<dynamic>) 2764 { 2765 var options = (IEnumerable<dynamic>) settings.Options; 2766 settings.Options = options.OrderBy(item => item.Name); 2767 } 2768 2769 foreach (var option in settings.Options) 2770 { 2771 selectedFilter = selectedFilter == option.Value ? option.Name : selectedFilter; 2772 } 2773 2774 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 2775 { 2776 <div class="u-pull--right u-margin-left"> 2777 <div class="collection u-no-margin"> 2778 <h5>@settings.Label</h5> 2779 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" /> 2780 <div class="dropdown u-w180px dw-mod"> 2781 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label> 2782 <div class="dropdown__content dw-mod"> 2783 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div> 2784 @foreach (var option in settings.Options) 2785 { 2786 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div> 2787 } 2788 </div> 2789 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label> 2790 </div> 2791 </div> 2792 </div> 2793 } 2794 else 2795 { 2796 <div class="u-full-width u-margin-bottom"> 2797 <h5 class="u-no-margin">@settings.Label</h5> 2798 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" /> 2799 <div class="dropdown u-full-width w-mod"> 2800 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label> 2801 <div class="dropdown__content dw-mod"> 2802 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div> 2803 @foreach (var option in settings.Options) 2804 { 2805 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div> 2806 } 2807 </div> 2808 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label> 2809 </div> 2810 </div> 2811 } 2812 } 2813 } 2814 @using System.Reflection 2815 @using Dynamicweb.Rapido.Blocks.Components 2816 @using Dynamicweb.Rapido.Blocks.Components.Articles 2817 @using Dynamicweb.Rapido.Blocks 2818 2819 @* Component for the articles *@ 2820 2821 @helper RenderArticleListSearch(ArticleListSearch settings) 2822 { 2823 string searchParameter = !string.IsNullOrEmpty(settings.SearchParameter) ? settings.SearchParameter : "Title"; 2824 string searchWord = HttpContext.Current.Request.QueryString.Get(searchParameter); 2825 string searchString = !string.IsNullOrEmpty(searchWord) ? searchWord.Trim('*') : ""; 2826 string className = "u-w340px u-pull--right u-margin-left"; 2827 2828 if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet") 2829 { 2830 className = "u-full-width"; 2831 } 2832 2833 <div class="typeahead u-color-inherit u-margin-bottom dw-mod @className"> 2834 <input type="text" class="typeahead-search-field u-no-margin dw-mod" placeholder="@Translate("Search in list")" value="@searchString" id="ArticleListSearchInput" onchange="QueryArray.setParameterInCurrentURL('@searchParameter', '*' + document.getElementById('ArticleListSearchInput').value + '*')"> 2835 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod"><i class="fas fa-search"></i></button> 2836 </div> 2837 } 2838 @using System.Reflection 2839 @using Dynamicweb.Rapido.Blocks.Components 2840 @using Dynamicweb.Rapido.Blocks.Components.Articles 2841 @using Dynamicweb.Rapido.Blocks 2842 2843 @* Component for the articles *@ 2844 2845 @helper RenderArticleListNoResultsInfo(ArticleListNoResultsInfo settings) 2846 { 2847 <div class="u-margin-top--lg u-bold u-ta-center u-bold">@Translate(settings.Message)</div> 2848 } 2849 @using System.Reflection 2850 @using Dynamicweb.Rapido.Blocks.Components 2851 @using Dynamicweb.Rapido.Blocks.Components.General 2852 @using Dynamicweb.Rapido.Blocks.Components.Articles 2853 @using Dynamicweb.Rapido.Blocks 2854 @using System.Text.RegularExpressions 2855 2856 @* Component for the articles *@ 2857 2858 @helper RenderArticleListItem(ArticleListItem settings) 2859 { 2860 switch (settings.Type) { 2861 case ArticleListItemType.Card: 2862 @RenderArticleListItemCard(settings); 2863 break; 2864 case ArticleListItemType.List: 2865 @RenderArticleListItemList(settings); 2866 break; 2867 case ArticleListItemType.Simple: 2868 @RenderArticleListItemSimple(settings); 2869 break; 2870 default: 2871 @RenderArticleListItemCard(settings); 2872 break; 2873 } 2874 } 2875 2876 @helper RenderArticleListItemCard(ArticleListItem settings) { 2877 <a href="@settings.Link" class="u-full-height u-color-light--bg"> 2878 <div class="u-color-light--bg u-no-padding dw-mod"> 2879 @if (settings.Logo != null) 2880 { 2881 string backgroundImage = settings.Image != null ? "background-image:url(/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=True&amp;image=" + settings.Image.Path + "); background-size: cover;" : ""; 2882 settings.Logo.ImageDefault.Crop = 5; 2883 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width; 2884 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height; 2885 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage"> 2886 @if (settings.Stickers != null) 2887 { 2888 if (settings.Stickers.Position != StickersListPosition.Custom) 2889 { 2890 @Render(settings.Stickers); 2891 } 2892 } 2893 @RenderImage(settings.Logo) 2894 </div> 2895 } else if (settings.Image != null) 2896 { 2897 <div class="flex-img image-hover__wrapper u-position-relative dw-mod"> 2898 @if (settings.Stickers != null) 2899 { 2900 if (settings.Stickers.Position != StickersListPosition.Custom) 2901 { 2902 @Render(settings.Stickers); 2903 } 2904 } 2905 @Render(settings.Image) 2906 </div> 2907 } 2908 </div> 2909 2910 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary)) 2911 { 2912 <div class="card u-color-light--bg dw-mod"> 2913 @if (settings.Stickers != null) 2914 { 2915 if (settings.Stickers.Position == StickersListPosition.Custom) 2916 { 2917 @Render(settings.Stickers); 2918 } 2919 } 2920 @if (!String.IsNullOrEmpty(settings.Title)) 2921 { 2922 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3> 2923 } 2924 @if (!String.IsNullOrEmpty(settings.SubTitle)) 2925 { 2926 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 2927 } 2928 @if (!String.IsNullOrEmpty(settings.Summary)) 2929 { 2930 <p class="article__short-summary dw-mod">@settings.Summary</p> 2931 } 2932 </div> 2933 } 2934 </a> 2935 } 2936 2937 @helper RenderArticleListItemList(ArticleListItem settings) { 2938 <a href="@settings.Link"> 2939 <div class="grid u-color-light--bg u-no-padding dw-mod"> 2940 <div class="grid__col-md-3"> 2941 <div class="u-color-light--bg u-no-padding dw-mod"> 2942 @if (settings.Logo != null) 2943 { 2944 string backgroundImage = settings.Image != null ? "background-image:url(/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=True&amp;image=" + settings.Image.Path + "); background-size: cover;" : ""; 2945 settings.Logo.ImageDefault.Crop = 5; 2946 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width; 2947 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height; 2948 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage"> 2949 @if (settings.Stickers != null) 2950 { 2951 if (settings.Stickers.Position != StickersListPosition.Custom) 2952 { 2953 @Render(settings.Stickers); 2954 } 2955 } 2956 @RenderImage(settings.Logo) 2957 </div> 2958 } else if (settings.Image != null) 2959 { 2960 <div class="flex-img image-hover__wrapper dw-mod"> 2961 @if (settings.Stickers != null) 2962 { 2963 if (settings.Stickers.Position != StickersListPosition.Custom) 2964 { 2965 @Render(settings.Stickers); 2966 } 2967 } 2968 @Render(settings.Image) 2969 </div> 2970 } 2971 </div> 2972 </div> 2973 2974 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary)) 2975 { 2976 <div class="grid__col-md-9"> 2977 @if (!String.IsNullOrEmpty(settings.Title)) 2978 { 2979 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3> 2980 } 2981 @if (settings.Stickers != null) 2982 { 2983 if (settings.Stickers.Position == StickersListPosition.Custom) 2984 { 2985 @Render(settings.Stickers); 2986 } 2987 } 2988 @if (!String.IsNullOrEmpty(settings.SubTitle)) 2989 { 2990 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 2991 } 2992 @if (!String.IsNullOrEmpty(settings.Summary)) 2993 { 2994 <p class="article__short-summary dw-mod">@settings.Summary</p> 2995 } 2996 </div> 2997 } 2998 </div> 2999 </a> 3000 } 3001 3002 @helper RenderArticleListItemSimple(ArticleListItem settings) { 3003 <a href="@settings.Link" class="u-color-inherit"> 3004 <div class="grid u-color-light--bg u-no-padding dw-mod"> 3005 <div class="grid__col-md-12"> 3006 @if (!String.IsNullOrEmpty(settings.Title)) 3007 { 3008 <div class="article-list-item__header u-truncate-text u-no-margin dw-mod">@settings.Title</div> 3009 } 3010 @if (!String.IsNullOrEmpty(settings.SubTitle)) 3011 { 3012 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 3013 } 3014 </div> 3015 </div> 3016 </a> 3017 } 3018 @using System.Reflection 3019 @using Dynamicweb.Rapido.Blocks.Components.Articles 3020 3021 3022 @* Component for the articles *@ 3023 3024 @helper RenderArticleAuthorAndDate(ArticleAuthorAndDate settings) 3025 { 3026 <small class="article__subscription"> 3027 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date))) 3028 { 3029 <text>@Translate("Written")</text> 3030 } 3031 @if (!string.IsNullOrWhiteSpace(settings.Author)) 3032 { 3033 <text>@Translate("by") @settings.Author</text> 3034 } 3035 @if (!string.IsNullOrWhiteSpace(settings.Date)) 3036 { 3037 <text>@Translate("on") @settings.Date</text> 3038 } 3039 </small> 3040 } 3041 @using System.Reflection 3042 @using Dynamicweb.Rapido.Blocks.Components.Articles 3043 @using Dynamicweb.Rapido.Blocks.Components.General 3044 3045 3046 @* Component for the articles *@ 3047 3048 @helper RenderArticleLink(ArticleLink settings) 3049 { 3050 if (!string.IsNullOrEmpty(settings.Title)) 3051 { 3052 Button link = new Button { 3053 ConfirmText = settings.ConfirmText, 3054 ConfirmTitle = settings.ConfirmTitle, 3055 ButtonType = settings.ButtonType, 3056 Id = settings.Id, 3057 Title = settings.Title, 3058 AltText = settings.AltText, 3059 OnClick = settings.OnClick, 3060 CssClass = settings.CssClass, 3061 Disabled = settings.Disabled, 3062 Icon = settings.Icon, 3063 Name = settings.Name, 3064 Href = settings.Href, 3065 ButtonLayout = settings.ButtonLayout, 3066 ExtraAttributes = settings.ExtraAttributes 3067 }; 3068 <div class="grid__cell"> 3069 @Render(link) 3070 </div> 3071 } 3072 } 3073 @using System.Reflection 3074 @using Dynamicweb.Rapido.Blocks 3075 @using Dynamicweb.Rapido.Blocks.Components.Articles 3076 @using Dynamicweb.Rapido.Blocks.Components.General 3077 3078 3079 @* Component for the articles *@ 3080 3081 @helper RenderArticleCarousel(ArticleCarousel settings) 3082 { 3083 <div class="grid"> 3084 <div class="grid__col-12"> 3085 <div class="carousel" id="carousel_@settings.Id"> 3086 <div class="carousel__container js-carousel-slides dw-mod"> 3087 @RenderBlockList(settings.SubBlocks) 3088 </div> 3089 </div> 3090 </div> 3091 </div> 3092 3093 <script> 3094 document.addEventListener("DOMContentLoaded", function () { 3095 new CarouselModule("#carousel_@settings.Id", { 3096 slideTime: 0, 3097 dots: true 3098 }); 3099 }); 3100 </script> 3101 } 3102 3103 @helper RenderArticleCarouselSlide(ArticleCarouselSlide settings) 3104 { 3105 string imageEngine = "/Admin/Public/GetImage.ashx?"; 3106 3107 string defaultImage = settings.ImageSettings != null ? imageEngine : settings.Image; 3108 if (settings.ImageSettings != null) 3109 { 3110 defaultImage += settings.ImageSettings.Width != 0 ? "Width=" + settings.ImageSettings.Width + "&" : ""; 3111 defaultImage += settings.ImageSettings.Height != 0 ? "Height=" + settings.ImageSettings.Height + "&" : ""; 3112 defaultImage += "Crop=" + settings.ImageSettings.Crop + "&"; 3113 defaultImage += "Compression=" + settings.ImageSettings.Compression + "&"; 3114 defaultImage += "DoNotUpscale=" + settings.ImageSettings.DoNotUpscale.ToString() + "&"; 3115 defaultImage += "FillCanvas=" + settings.ImageSettings.FillCanvas.ToString() + "&"; 3116 } 3117 defaultImage += "&Image=" + settings.Image; 3118 3119 <div class="carousel__slide u-min-h300px u-flex dw-mod" style="background-size:cover; background-image:url('@defaultImage')"> 3120 <a class="article-carousel-item__wrap" href="@settings.Link" title="@settings.Title"> 3121 <h2 class="article-list__item-header u-truncate-text u-color-light dw-mod">@settings.Title</h2> 3122 <div class="article-list__item-info"> 3123 @if (settings.Stickers != null) 3124 { 3125 settings.Stickers.Position = StickersListPosition.Custom; 3126 @Render(settings.Stickers); 3127 } 3128 3129 <small class="u-margin-top--lg u-color-light"> 3130 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date))) 3131 { 3132 <text>@Translate("Written")</text> 3133 } 3134 @if (!string.IsNullOrWhiteSpace(settings.Author)) 3135 { 3136 <text>@Translate("by") @settings.Author</text> 3137 } 3138 @if (!string.IsNullOrWhiteSpace(settings.Date)) 3139 { 3140 <text>@Translate("on") @settings.Date</text> 3141 } 3142 </small> 3143 </div> 3144 3145 <h3 class="article__short-summary u-color-light">@settings.Summary</h3> 3146 </a> 3147 @if (settings.UseFilters == true) 3148 { 3149 <div class="background-image image-filter image-filter--darken dw-mod"></div> 3150 } 3151 </div> 3152 } 3153 @using System.Text.RegularExpressions 3154 @using Dynamicweb.Rapido.Blocks.Components 3155 @using Dynamicweb.Rapido.Blocks.Components.General 3156 @using Dynamicweb.Rapido.Blocks.Components.Articles 3157 @using Dynamicweb.Rapido.Blocks 3158 3159 @* Component for the articles *@ 3160 3161 @helper RenderArticleVideo(ArticleVideo settings) 3162 { 3163 if (settings.Url != null) 3164 { 3165 //getting video ID from youtube URL 3166 string videoCode = settings.Url; 3167 Regex regex = new Regex(@".be\/(.[^?]*)"); 3168 Match match = regex.Match(videoCode); 3169 string videoId = ""; 3170 if (match.Success) 3171 { 3172 videoId = match.Groups[1].Value; 3173 } 3174 else 3175 { 3176 regex = new Regex(@"v=([^&]+)"); 3177 match = regex.Match(videoCode); 3178 if (match.Success) 3179 { 3180 videoId = match.Groups[1].Value; 3181 } 3182 } 3183 3184 int autoPlay = settings.AutoPlay == "true" ? 1 : 0; 3185 3186 <div class="video-wrapper"> 3187 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Guid.NewGuid().ToString("N"))" data-auto-play="@autoPlay" data-enable-controls="1"></div> 3188 </div> 3189 } 3190 } 3191 3192 3193 3194 @* Simple helpers *@ 3195 3196 @*Requires the Gallery ItemType that comes with Rapido*@ 3197 @helper RenderArticleItemGallery(IList<ItemViewModel> gallery) { 3198 if (gallery != null && gallery.Count > 0) 3199 { 3200 int count = 1; 3201 3202 foreach (var item in gallery) 3203 { 3204 if (item.GetFile("ImagePath") != null) 3205 { 3206 string image = item.GetFile("ImagePath").PathUrlEncoded; 3207 string imagePrefix = "/Admin/Public/GetImage.ashx?width=1200&amp;height=820&amp;crop=5&amp;Compression=75&amp;DoNotUpscale=1&amp;image="; 3208 int imagesCount = gallery.Count; 3209 3210 if (count == 1) 3211 { 3212 <label class="gallery" for="ParagraphGalleryModalTrigger" onclick="Gallery.openImage(this.querySelector('.js-gallery'))"> 3213 <span class="gallery__main-image"> 3214 <img src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=1&amp;image=@image" class="b-lazy flex-img js-gallery" alt="" data-for="ParagraphGallery" data-image="@imagePrefix@image" /> 3215 </span> 3216 <span class="gallery__image-counter"> 3217 <i class="fas fa-camera fa-2x"></i> <span class="gallery__image-counter__number">@imagesCount</span> 3218 <span class="gallery__image-counter__text">@Translate("See all") <i class="fas fa-angle-right"></i></span> 3219 </span> 3220 </label> 3221 } 3222 else 3223 { 3224 <div class="u-hidden js-gallery" data-for="ParagraphGallery" data-image="@imagePrefix@image"></div> 3225 } 3226 3227 count++; 3228 } 3229 } 3230 3231 @Render(new ArticleGalleryModal()) 3232 } 3233 } 3234 3235 @helper RenderMobileFilters(List<Block> subBlocks) 3236 { 3237 if (subBlocks.Count > 0) 3238 { 3239 <div class="grid__col-12"> 3240 <input type="checkbox" id="CheckFilters" class="js-remember-state u-hidden" data-expand="CheckFilters" /> 3241 <div class="grid u-margin-bottom dw-mod" data-trigger="CheckFilters"> 3242 @RenderBlockList(subBlocks) 3243 </div> 3244 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod js-expand-hide" data-trigger="CheckFilters">@Translate("Select filters")</label> 3245 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod expandable--collapsed" data-trigger="CheckFilters">@Translate("Close filters")</label> 3246 </div> 3247 } 3248 } 3249 3250 3251 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 3252 @RenderBlockList(articleListParagraph.BlocksRoot.BlocksList)

Employee

BC

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