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