Error executing template "/Designs/Rapido/Paragraph/Custom__ShoppingTools.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_ee67899a01514fcf8cda257849364c4b.Execute() in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\Paragraph\Custom__ShoppingTools.cshtml:line 2354
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

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