Oppblåsbare Spa

Error executing template "Designs/Rapido/ContentPage/Paragraph/CardParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_d6c85d11753c487e8c10951c6f67fb45.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Novicell\Denform\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2201
   at CompiledRazorTemplates.Dynamic.RazorEngine_d6c85d11753c487e8c10951c6f67fb45.Execute() in D:\dynamicweb.net\Solutions\Novicell\Denform\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2138
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Content.Items 4 @using Dynamicweb 5 @using Dynamicweb.Rapido.Blocks.Components 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 8 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 9 @using Dynamicweb.Frontend 10 11 @* Include the components *@ 12 @using System.Text.RegularExpressions 13 @using System.Collections.Generic 14 @using System.Reflection 15 @using System.Web 16 @using System.Web.UI.HtmlControls 17 @using Dynamicweb.Rapido.Blocks.Components 18 @using Dynamicweb.Rapido.Blocks.Components.Articles 19 @using Dynamicweb.Rapido.Blocks.Components.Documentation 20 @using Dynamicweb.Rapido.Blocks 21 22 23 @*--- START: Base block renderers ---*@ 24 25 @helper RenderBlockList(List<Block> blocks) 26 { 27 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 28 blocks = blocks.OrderBy(item => item.SortId).ToList(); 29 30 foreach (Block item in blocks) 31 { 32 if (debug) { 33 <!-- Block START: @item.Id --> 34 } 35 36 if (item.Design == null) 37 { 38 @RenderBlock(item) 39 } 40 else if (item.Design.RenderType == RenderType.None) { 41 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 42 43 <div class="@cssClass dw-mod"> 44 @RenderBlock(item) 45 </div> 46 } 47 else if (item.Design.RenderType != RenderType.Hide) 48 { 49 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 50 51 if (!item.SkipRenderBlocksList) { 52 if (item.Design.RenderType == RenderType.Row) 53 { 54 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 55 @RenderBlock(item) 56 </div> 57 } 58 59 if (item.Design.RenderType == RenderType.Column) 60 { 61 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 62 string size = item.Design.Size ?? "12"; 63 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 64 65 <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"> 66 @RenderBlock(item) 67 </div> 68 } 69 70 if (item.Design.RenderType == RenderType.Table) 71 { 72 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 73 @RenderBlock(item) 74 </table> 75 } 76 77 if (item.Design.RenderType == RenderType.TableRow) 78 { 79 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 80 @RenderBlock(item) 81 </tr> 82 } 83 84 if (item.Design.RenderType == RenderType.TableColumn) 85 { 86 <td class="@cssClass dw-mod" id="Block__@item.Id"> 87 @RenderBlock(item) 88 </td> 89 } 90 91 if (item.Design.RenderType == RenderType.CardHeader) 92 { 93 <div class="card-header @cssClass dw-mod"> 94 @RenderBlock(item) 95 </div> 96 } 97 98 if (item.Design.RenderType == RenderType.CardBody) 99 { 100 <div class="card @cssClass dw-mod"> 101 @RenderBlock(item) 102 </div> 103 } 104 105 if (item.Design.RenderType == RenderType.CardFooter) 106 { 107 <div class="card-footer @cssClass dw-mod"> 108 @RenderBlock(item) 109 </div> 110 } 111 } 112 else 113 { 114 @RenderBlock(item) 115 } 116 } 117 118 if (debug) { 119 <!-- Block END: @item.Id --> 120 } 121 } 122 } 123 124 @helper RenderBlock(Block item) 125 { 126 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 127 128 if (item.Template != null) 129 { 130 @BlocksPage.RenderTemplate(item.Template) 131 } 132 133 if (item.Component != null) 134 { 135 string customSufix = "Custom"; 136 string methodName = item.Component.HelperName; 137 138 ComponentBase[] methodParameters = new ComponentBase[1]; 139 methodParameters[0] = item.Component; 140 Type methodType = this.GetType(); 141 142 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 143 144 try { 145 if (debug) { 146 <!-- Component: @methodName.Replace("Render", "") --> 147 } 148 if(customMethod != null) { 149 @customMethod.Invoke(this, methodParameters).ToString(); 150 } else { 151 MethodInfo generalMethod = methodType.GetMethod(methodName); 152 @generalMethod.Invoke(this, methodParameters).ToString(); 153 } 154 } catch { 155 try { 156 MethodInfo generalMethod = methodType.GetMethod(methodName); 157 @generalMethod.Invoke(this, methodParameters).ToString(); 158 } catch(Exception ex) { 159 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 160 } 161 } 162 } 163 164 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 165 { 166 @RenderBlockList(item.BlocksList) 167 } 168 } 169 170 @*--- END: Base block renderers ---*@ 171 172 @using Dynamicweb.Rapido.Blocks.Components 173 @using Dynamicweb.Rapido.Blocks.Components.General 174 @using Dynamicweb.Rapido.Blocks 175 @using System.IO 176 177 @* Required *@ 178 @using Dynamicweb.Rapido.Blocks.Components 179 @using Dynamicweb.Rapido.Blocks.Components.General 180 @using Dynamicweb.Rapido.Blocks 181 182 183 @helper Render(ComponentBase component) 184 { 185 if (component != null) 186 { 187 @component.Render(this) 188 } 189 } 190 191 @* Components *@ 192 @using System.Reflection 193 @using Dynamicweb.Rapido.Blocks.Components.General 194 195 196 @* Component *@ 197 198 @helper RenderIcon(Icon settings) 199 { 200 if (settings != null) 201 { 202 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 203 204 if (settings.Name != null) 205 { 206 if (string.IsNullOrEmpty(settings.Label)) 207 { 208 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 209 } 210 else 211 { 212 if (settings.LabelPosition == IconLabelPosition.Before) 213 { 214 <div class="u-flex u-flex--align-items-center @settings.CssClass">@settings.Label <i class="@settings.Prefix @settings.Name u-margin-left" @color></i></div> 215 } 216 else 217 { 218 <div class="u-flex u-flex--align-items-center @settings.CssClass"><i class="@settings.Prefix @settings.Name u-margin-right--lg u-w20px" @color></i>@settings.Label</div> 219 } 220 } 221 } 222 else if (!string.IsNullOrEmpty(settings.Label)) 223 { 224 @settings.Label 225 } 226 } 227 } 228 @using System.Reflection 229 @using Dynamicweb.Rapido.Blocks.Components.General 230 @using Dynamicweb.Rapido.Blocks.Components 231 @using Dynamicweb.Core 232 233 @* Component *@ 234 235 @helper RenderButton(Button settings) 236 { 237 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 238 { 239 Dictionary<string, string> attributes = new Dictionary<string, string>(); 240 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 241 if (settings.Disabled) { 242 attributes.Add("disabled", "true"); 243 classList.Add("disabled"); 244 } 245 246 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 247 { 248 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 249 @RenderConfirmDialog(settings); 250 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 251 } 252 253 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 254 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 255 if (!string.IsNullOrEmpty(settings.AltText)) 256 { 257 attributes.Add("title", settings.AltText); 258 } 259 else if (!string.IsNullOrEmpty(settings.Title)) 260 { 261 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 262 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 263 attributes.Add("title", cleanTitle); 264 } 265 266 var onClickEvents = new List<string>(); 267 if (!string.IsNullOrEmpty(settings.OnClick)) 268 { 269 onClickEvents.Add(settings.OnClick); 270 } 271 if (!string.IsNullOrEmpty(settings.Href)) 272 { 273 onClickEvents.Add("location.href='" + settings.Href + "'"); 274 } 275 if (onClickEvents.Count > 0) 276 { 277 attributes.Add("onClick", string.Join(";", onClickEvents)); 278 } 279 280 if (settings.ButtonLayout != ButtonLayout.None) 281 { 282 classList.Add("btn"); 283 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 284 if (btnLayout == "linkclean") 285 { 286 btnLayout = "link-clean"; //fix 287 } 288 classList.Add("btn--" + btnLayout); 289 } 290 291 if (settings.Icon == null) 292 { 293 settings.Icon = new Icon(); 294 } 295 296 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 297 settings.Icon.Label = settings.Title; 298 299 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 300 301 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 302 } 303 } 304 305 @helper RenderConfirmDialog(Button settings) 306 { 307 Modal confirmDialog = new Modal { 308 Id = settings.Id, 309 Width = ModalWidth.Sm, 310 Heading = new Heading 311 { 312 Level = 2, 313 Title = settings.ConfirmTitle 314 }, 315 BodyText = settings.ConfirmText 316 }; 317 318 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 319 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 320 321 @Render(confirmDialog) 322 } 323 @using Dynamicweb.Rapido.Blocks.Components.General 324 @using Dynamicweb.Rapido.Blocks.Components 325 @using Dynamicweb.Core 326 327 @helper RenderDashboard(Dashboard settings) 328 { 329 var widgets = settings.GetWidgets(); 330 331 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 332 { 333 //set bg color for them 334 335 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 336 int r = Convert.ToInt16(color.R); 337 int g = Convert.ToInt16(color.G); 338 int b = Convert.ToInt16(color.B); 339 340 var count = widgets.Length; 341 var max = Math.Max(r, Math.Max(g, b)); 342 double step = 255.0 / (max * count); 343 var i = 0; 344 foreach (var widget in widgets) 345 { 346 i++; 347 348 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 349 widget.BackgroundColor = shade; 350 } 351 } 352 353 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 354 @foreach (var widget in widgets) 355 { 356 <div class="dashboard__widget"> 357 @Render(widget) 358 </div> 359 } 360 </div> 361 } 362 @using Dynamicweb.Rapido.Blocks.Components.General 363 @using Dynamicweb.Rapido.Blocks.Components 364 365 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 366 { 367 if (!string.IsNullOrEmpty(settings.Link)) 368 { 369 var backgroundStyles = ""; 370 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 371 { 372 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 373 } 374 375 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 376 <div class="u-center-middle u-color-light"> 377 @if (settings.Icon != null) 378 { 379 settings.Icon.CssClass += "widget__icon"; 380 @Render(settings.Icon) 381 } 382 <div class="widget__title">@settings.Title</div> 383 </div> 384 </a> 385 } 386 } 387 @using Dynamicweb.Rapido.Blocks.Components.General 388 @using Dynamicweb.Rapido.Blocks.Components 389 390 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 391 { 392 var backgroundStyles = ""; 393 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 394 { 395 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 396 } 397 398 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 399 <div class="u-center-middle u-color-light"> 400 @if (settings.Icon != null) 401 { 402 settings.Icon.CssClass += "widget__icon"; 403 @Render(settings.Icon) 404 } 405 <div class="widget__counter">@settings.Count</div> 406 <div class="widget__title">@settings.Title</div> 407 </div> 408 </div> 409 } 410 @using System.Reflection 411 @using Dynamicweb.Rapido.Blocks.Components.General 412 @using Dynamicweb.Rapido.Blocks.Components 413 @using Dynamicweb.Core 414 415 @* Component *@ 416 417 @helper RenderLink(Link settings) 418 { 419 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 420 { 421 Dictionary<string, string> attributes = new Dictionary<string, string>(); 422 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 423 if (settings.Disabled) 424 { 425 attributes.Add("disabled", "true"); 426 classList.Add("disabled"); 427 } 428 429 if (!string.IsNullOrEmpty(settings.AltText)) 430 { 431 attributes.Add("title", settings.AltText); 432 } 433 else if (!string.IsNullOrEmpty(settings.Title)) 434 { 435 attributes.Add("title", settings.Title); 436 } 437 438 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 439 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 440 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 441 attributes.Add("href", settings.Href); 442 443 if (settings.ButtonLayout != ButtonLayout.None) 444 { 445 classList.Add("btn"); 446 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 447 if (btnLayout == "linkclean") 448 { 449 btnLayout = "link-clean"; //fix 450 } 451 classList.Add("btn--" + btnLayout); 452 } 453 454 if (settings.Icon == null) 455 { 456 settings.Icon = new Icon(); 457 } 458 settings.Icon.Label = settings.Title; 459 460 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 461 { 462 settings.Rel = LinkRelType.Noopener; 463 } 464 if (settings.Target != LinkTargetType.None) 465 { 466 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 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"> 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"> 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 alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 690 string placeholderImage = "/Files/Images/placeholder.gif"; 691 string imageEngine = "/Admin/Public/GetImage.ashx?"; 692 693 string imageStyle = ""; 694 695 switch (settings.Style) 696 { 697 case ImageStyle.Ball: 698 imageStyle = "grid__cell-img--ball"; 699 break; 700 701 case ImageStyle.Triangle: 702 imageStyle = "grid__cell-img--triangle"; 703 break; 704 } 705 706 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 707 { 708 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 709 710 if (settings.ImageDefault != null) 711 { 712 settings.ImageDefault.Height = settings.ImageDefault.Width; 713 } 714 if (settings.ImageMedium != null) 715 { 716 settings.ImageMedium.Height = settings.ImageMedium.Width; 717 } 718 if (settings.ImageSmall != null) 719 { 720 settings.ImageSmall.Height = settings.ImageSmall.Width; 721 } 722 } 723 724 string defaultImage = imageEngine; 725 string imageSmall = ""; 726 string imageMedium = ""; 727 728 if (settings.DisableImageEngine) 729 { 730 defaultImage = settings.Path; 731 } 732 else 733 { 734 if (settings.ImageDefault != null) 735 { 736 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 737 738 if (settings.Path.GetType() != typeof(string)) 739 { 740 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 741 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 742 } 743 else 744 { 745 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 746 } 747 748 defaultImage += "&AlternativeImage=" + alternativeImage; 749 } 750 751 if (settings.ImageSmall != null) 752 { 753 imageSmall = "data-src-small=\"" + imageEngine; 754 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 755 756 if (settings.Path.GetType() != typeof(string)) 757 { 758 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 759 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 760 } 761 else 762 { 763 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 764 } 765 766 imageSmall += "&alternativeImage=" + alternativeImage; 767 768 imageSmall += "\""; 769 } 770 771 if (settings.ImageMedium != null) 772 { 773 imageMedium = "data-src-medium=\"" + imageEngine; 774 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 775 776 if (settings.Path.GetType() != typeof(string)) 777 { 778 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 779 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 780 } 781 else 782 { 783 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 784 } 785 786 imageMedium += "&alternativeImage=" + alternativeImage; 787 788 imageMedium += "\""; 789 } 790 } 791 792 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 793 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 794 if (!string.IsNullOrEmpty(settings.Title)) 795 { 796 optionalAttributes.Add("alt", settings.Title); 797 optionalAttributes.Add("title", settings.Title); 798 } 799 800 if (settings.DisableLazyLoad) 801 { 802 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 803 } 804 else 805 { 806 <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) /> 807 } 808 } 809 } 810 @using System.Reflection 811 @using Dynamicweb.Rapido.Blocks.Components.General 812 @using Dynamicweb.Rapido.Blocks.Components 813 814 @* Component *@ 815 816 @helper RenderFileField(FileField settings) 817 { 818 var attributes = new Dictionary<string, string>(); 819 if (string.IsNullOrEmpty(settings.Id)) 820 { 821 settings.Id = Guid.NewGuid().ToString("N"); 822 } 823 824 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 825 if (settings.Disabled) { attributes.Add("disabled", "true"); } 826 if (settings.Required) { attributes.Add("required", "true"); } 827 if (settings.Multiple) { attributes.Add("multiple", "true"); } 828 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 829 if (string.IsNullOrEmpty(settings.ChooseFileText)) 830 { 831 settings.ChooseFileText = Translate("Choose file"); 832 } 833 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 834 { 835 settings.NoFilesChosenText = Translate("No files chosen..."); 836 } 837 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 838 839 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 840 841 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 842 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 843 844 attributes.Add("type", "file"); 845 if (settings.Value != null) { attributes.Add("value", settings.Value); } 846 settings.CssClass = "u-full-width " + settings.CssClass; 847 848 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 849 850 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 851 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 852 { 853 <div class="u-full-width"> 854 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 855 @if (settings.Link != null) { 856 <div class="u-pull--right"> 857 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 858 @Render(settings.Link) 859 </div> 860 } 861 </div> 862 863 } 864 865 @if (!string.IsNullOrEmpty(settings.HelpText)) 866 { 867 <small class="form__help-text">@settings.HelpText</small> 868 } 869 870 <div class="form__field-combi file-input u-no-margin dw-mod"> 871 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 872 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 873 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 874 @if (settings.UploadButton != null) 875 { 876 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 877 @Render(settings.UploadButton) 878 } 879 </div> 880 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 881 </div> 882 } 883 @using System.Reflection 884 @using Dynamicweb.Rapido.Blocks.Components.General 885 @using Dynamicweb.Rapido.Blocks.Components 886 @using Dynamicweb.Core 887 @using System.Linq 888 889 @* Component *@ 890 891 @helper RenderDateTimeField(DateTimeField settings) 892 { 893 if (string.IsNullOrEmpty(settings.Id)) 894 { 895 settings.Id = Guid.NewGuid().ToString("N"); 896 } 897 898 var textField = new TextField { 899 Name = settings.Name, 900 Id = settings.Id, 901 Label = settings.Label, 902 HelpText = settings.HelpText, 903 Value = settings.Value, 904 Disabled = settings.Disabled, 905 Required = settings.Required, 906 ErrorMessage = settings.ErrorMessage, 907 CssClass = settings.CssClass, 908 WrapperCssClass = settings.WrapperCssClass, 909 OnChange = settings.OnChange, 910 OnClick = settings.OnClick, 911 Link = settings.Link, 912 ExtraAttributes = settings.ExtraAttributes, 913 // 914 Placeholder = settings.Placeholder 915 }; 916 917 @Render(textField) 918 919 List<string> jsAttributes = new List<string>(); 920 921 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 922 923 if (!string.IsNullOrEmpty(settings.DateFormat)) 924 { 925 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 926 } 927 if (!string.IsNullOrEmpty(settings.MinDate)) 928 { 929 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 930 } 931 if (!string.IsNullOrEmpty(settings.MaxDate)) 932 { 933 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 934 } 935 if (settings.IsInline) 936 { 937 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 938 } 939 if (settings.EnableTime) 940 { 941 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 942 } 943 if (settings.EnableWeekNumbers) 944 { 945 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 946 } 947 948 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 949 950 <script> 951 document.addEventListener("DOMContentLoaded", function () { 952 flatpickr("#@textField.Id", { 953 @string.Join(",", jsAttributes) 954 }); 955 }); 956 </script> 957 } 958 @using System.Reflection 959 @using Dynamicweb.Rapido.Blocks.Components.General 960 @using Dynamicweb.Rapido.Blocks.Components 961 962 @* Component *@ 963 964 @helper RenderTextField(TextField settings) 965 { 966 var attributes = new Dictionary<string, string>(); 967 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 968 { 969 settings.Id = Guid.NewGuid().ToString("N"); 970 } 971 972 /*base settings*/ 973 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 974 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 975 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 976 if (settings.Disabled) { attributes.Add("disabled", "true"); } 977 if (settings.Required) { attributes.Add("required", "true"); } 978 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 979 /*end*/ 980 981 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 982 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 983 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 984 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 985 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 986 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 987 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 988 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 989 if (settings.Value != null) { attributes.Add("value", settings.Value); } 990 991 settings.CssClass = "u-full-width " + settings.CssClass; 992 993 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 994 995 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 996 997 string noMargin = "u-no-margin"; 998 if (!settings.ReadOnly) { 999 noMargin = ""; 1000 } 1001 1002 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1003 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1004 { 1005 <div class="u-full-width"> 1006 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1007 @if (settings.Link != null) { 1008 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1009 1010 <div class="u-pull--right"> 1011 @Render(settings.Link) 1012 </div> 1013 } 1014 </div> 1015 1016 } 1017 1018 @if (!string.IsNullOrEmpty(settings.HelpText)) 1019 { 1020 <small class="form__help-text">@settings.HelpText</small> 1021 } 1022 1023 @if (settings.ActionButton != null) 1024 { 1025 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1026 <div class="form__field-combi u-no-margin dw-mod"> 1027 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1028 @Render(settings.ActionButton) 1029 </div> 1030 } 1031 else 1032 { 1033 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1034 } 1035 1036 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1037 </div> 1038 } 1039 @using System.Reflection 1040 @using Dynamicweb.Rapido.Blocks.Components.General 1041 @using Dynamicweb.Rapido.Blocks.Components 1042 1043 @* Component *@ 1044 1045 @helper RenderNumberField(NumberField settings) 1046 { 1047 var attributes = new Dictionary<string, string>(); 1048 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1049 { 1050 settings.Id = Guid.NewGuid().ToString("N"); 1051 } 1052 1053 /*base settings*/ 1054 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1055 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1056 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1057 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1058 if (settings.Required) { attributes.Add("required", "true"); } 1059 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1060 /*end*/ 1061 1062 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1063 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1064 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1065 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1066 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1067 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1068 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1069 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1070 attributes.Add("type", "number"); 1071 1072 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1073 1074 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1075 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1076 { 1077 <div class="u-full-width"> 1078 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1079 @if (settings.Link != null) { 1080 <div class="u-pull--right"> 1081 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1082 @Render(settings.Link) 1083 </div> 1084 } 1085 </div> 1086 1087 } 1088 1089 @if (!string.IsNullOrEmpty(settings.HelpText)) 1090 { 1091 <small class="form__help-text">@settings.HelpText</small> 1092 } 1093 1094 @if (settings.ActionButton != null) 1095 { 1096 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1097 <div class="form__field-combi u-no-margin dw-mod"> 1098 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1099 @Render(settings.ActionButton) 1100 </div> 1101 } 1102 else 1103 { 1104 <div class="form__field-combi u-no-margin dw-mod"> 1105 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1106 </div> 1107 } 1108 1109 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1110 </div> 1111 } 1112 @using System.Reflection 1113 @using Dynamicweb.Rapido.Blocks.Components.General 1114 @using Dynamicweb.Rapido.Blocks.Components 1115 1116 1117 @* Component *@ 1118 1119 @helper RenderTextareaField(TextareaField settings) 1120 { 1121 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1122 string id = settings.Id; 1123 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1124 { 1125 id = Guid.NewGuid().ToString("N"); 1126 } 1127 1128 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1129 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1130 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1131 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1132 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1133 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1134 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1135 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1136 if (settings.Required) { attributes.Add("required", "true"); } 1137 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1138 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1139 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1140 attributes.Add("name", settings.Name); 1141 1142 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1143 1144 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1145 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1146 { 1147 <div class="u-full-width"> 1148 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1149 @if (settings.Link != null) { 1150 <div class="u-pull--right"> 1151 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1152 @Render(settings.Link) 1153 </div> 1154 } 1155 </div> 1156 } 1157 1158 @if (!string.IsNullOrEmpty(settings.HelpText)) 1159 { 1160 <small class="form__help-text">@settings.HelpText</small> 1161 } 1162 1163 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1164 1165 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1166 </div> 1167 } 1168 @using System.Reflection 1169 @using Dynamicweb.Rapido.Blocks.Components.General 1170 @using Dynamicweb.Rapido.Blocks.Components 1171 1172 1173 @* Component *@ 1174 1175 @helper RenderHiddenField(HiddenField settings) { 1176 var attributes = new Dictionary<string, string>(); 1177 attributes.Add("type", "hidden"); 1178 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1179 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1180 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1181 1182 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1183 } 1184 @using System.Reflection 1185 @using Dynamicweb.Rapido.Blocks.Components.General 1186 @using Dynamicweb.Rapido.Blocks.Components 1187 1188 @* Component *@ 1189 1190 @helper RenderCheckboxField(CheckboxField settings) 1191 { 1192 var attributes = new Dictionary<string, string>(); 1193 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1194 { 1195 settings.Id = Guid.NewGuid().ToString("N"); 1196 } 1197 1198 /*base settings*/ 1199 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1200 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1201 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1202 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1203 if (settings.Required) { attributes.Add("required", "true"); } 1204 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1205 /*end*/ 1206 1207 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1208 1209 attributes.Add("type", "checkbox"); 1210 if (settings.Checked) { attributes.Add("checked", "true"); } 1211 settings.CssClass = "form__control " + settings.CssClass; 1212 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1213 1214 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1215 1216 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1217 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1218 @if (!string.IsNullOrEmpty(settings.Label)) 1219 { 1220 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1221 } 1222 1223 @if (settings.Link != null) { 1224 <span> 1225 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1226 @Render(settings.Link) 1227 </span> 1228 } 1229 1230 @if (!string.IsNullOrEmpty(settings.HelpText)) 1231 { 1232 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1233 } 1234 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1235 </div> 1236 } 1237 @using System.Reflection 1238 @using Dynamicweb.Rapido.Blocks.Components.General 1239 @using Dynamicweb.Rapido.Blocks.Components 1240 1241 1242 @* Component *@ 1243 1244 @helper RenderCheckboxListField(CheckboxListField settings) 1245 { 1246 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1247 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1248 { 1249 <div class="u-full-width"> 1250 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1251 @if (settings.Link != null) { 1252 <div class="u-pull--right"> 1253 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1254 @Render(settings.Link) 1255 </div> 1256 } 1257 </div> 1258 1259 } 1260 1261 <div class="u-pull--left"> 1262 @if (!string.IsNullOrEmpty(settings.HelpText)) 1263 { 1264 <small class="form__help-text">@settings.HelpText</small> 1265 } 1266 1267 @foreach (var item in settings.Options) 1268 { 1269 if (settings.Required) 1270 { 1271 item.Required = true; 1272 } 1273 if (settings.Disabled) 1274 { 1275 item.Disabled = true; 1276 } 1277 if (!string.IsNullOrEmpty(settings.Name)) 1278 { 1279 item.Name = settings.Name; 1280 } 1281 if (!string.IsNullOrEmpty(settings.CssClass)) 1282 { 1283 item.CssClass += settings.CssClass; 1284 } 1285 1286 /* value is not supported */ 1287 1288 if (!string.IsNullOrEmpty(settings.OnClick)) 1289 { 1290 item.OnClick += settings.OnClick; 1291 } 1292 if (!string.IsNullOrEmpty(settings.OnChange)) 1293 { 1294 item.OnChange += settings.OnChange; 1295 } 1296 @Render(item) 1297 } 1298 1299 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1300 </div> 1301 1302 </div> 1303 } 1304 @using Dynamicweb.Rapido.Blocks.Components.General 1305 1306 @* Component *@ 1307 1308 @helper RenderSearch(Search settings) 1309 { 1310 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1311 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1312 1313 if (string.IsNullOrEmpty(settings.Id)) 1314 { 1315 settings.Id = Guid.NewGuid().ToString("N"); 1316 } 1317 1318 var resultAttributes = new Dictionary<string, string>(); 1319 1320 if (settings.PageSize != 0) 1321 { 1322 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1323 } 1324 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1325 { 1326 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1327 if (!string.IsNullOrEmpty(groupValue)) 1328 { 1329 resultAttributes.Add("data-selected-group", groupValue); 1330 } 1331 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1332 { 1333 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1334 } 1335 } 1336 resultAttributes.Add("data-force-init", "true"); 1337 if (settings.GoToFirstSearchResultOnEnter) 1338 { 1339 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1340 } 1341 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1342 { 1343 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1344 } 1345 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1346 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1347 1348 if (settings.SecondSearchData != null) 1349 { 1350 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1351 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1352 } 1353 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1354 { 1355 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1356 } 1357 1358 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1359 1360 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1361 1362 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1363 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1364 { 1365 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1366 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1367 } 1368 1369 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1370 1371 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1372 @if (settings.SecondSearchData != null) 1373 { 1374 <div class="search__column search__column--products dw-mod"> 1375 <div class="search__column-header dw-mod">@Translate("Products")</div> 1376 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1377 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1378 { 1379 @Render(new Link { 1380 Title = Translate("View all"), 1381 CssClass = "js-view-all-button u-margin", 1382 Href = settings.SearchData.ResultsPageUrl 1383 }); 1384 } 1385 </div> 1386 <div class="search__column search__column--pages dw-mod"> 1387 <div class="search__column-header">@Translate("Pages")</div> 1388 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1389 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1390 { 1391 @Render(new Link 1392 { 1393 Title = Translate("View all"), 1394 CssClass = "js-view-all-button u-margin", 1395 Href = settings.SecondSearchData.ResultsPageUrl 1396 }); 1397 } 1398 </div> 1399 } 1400 else 1401 { 1402 <div class="search__column search__column--only dw-mod"> 1403 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1404 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1405 { 1406 @Render(new Link { 1407 Title = Translate("View all"), 1408 CssClass = "js-view-all-button u-margin", 1409 Href = settings.SearchData.ResultsPageUrl 1410 }); 1411 } 1412 </div> 1413 } 1414 </div> 1415 1416 @if (settings.SearchButton != null) 1417 { 1418 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1419 if (settings.RenderDefaultSearchIcon) 1420 { 1421 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1422 } 1423 @Render(settings.SearchButton); 1424 } 1425 </div> 1426 } 1427 @using System.Reflection 1428 @using Dynamicweb.Rapido.Blocks.Components.General 1429 @using Dynamicweb.Rapido.Blocks.Components 1430 1431 1432 @* Component *@ 1433 1434 @helper RenderSelectField(SelectField settings) 1435 { 1436 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1437 { 1438 settings.Id = Guid.NewGuid().ToString("N"); 1439 } 1440 1441 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1442 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1443 { 1444 <div class="u-full-width"> 1445 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1446 @if (settings.Link != null) { 1447 <div class="u-pull--right"> 1448 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1449 @Render(settings.Link) 1450 </div> 1451 } 1452 </div> 1453 } 1454 1455 @if (!string.IsNullOrEmpty(settings.HelpText)) 1456 { 1457 <small class="form__help-text">@settings.HelpText</small> 1458 } 1459 1460 @if (settings.ActionButton != null) 1461 { 1462 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1463 <div class="form__field-combi u-no-margin dw-mod"> 1464 @RenderSelectBase(settings) 1465 @Render(settings.ActionButton) 1466 </div> 1467 } 1468 else 1469 { 1470 @RenderSelectBase(settings) 1471 } 1472 1473 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1474 </div> 1475 } 1476 1477 @helper RenderSelectBase(SelectField settings) 1478 { 1479 var attributes = new Dictionary<string, string>(); 1480 1481 /*base settings*/ 1482 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1483 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1484 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1485 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1486 if (settings.Required) { attributes.Add("required", "true"); } 1487 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1488 /*end*/ 1489 1490 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1491 1492 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1493 @if (settings.Default != null) 1494 { 1495 @Render(settings.Default) 1496 } 1497 1498 @foreach (var item in settings.Options) 1499 { 1500 if (settings.Value != null) { 1501 item.Checked = item.Value == settings.Value; 1502 } 1503 @Render(item) 1504 } 1505 </select> 1506 } 1507 @using System.Reflection 1508 @using Dynamicweb.Rapido.Blocks.Components.General 1509 @using Dynamicweb.Rapido.Blocks.Components 1510 1511 @* Component *@ 1512 1513 @helper RenderRadioButtonField(RadioButtonField settings) 1514 { 1515 var attributes = new Dictionary<string, string>(); 1516 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1517 { 1518 settings.Id = Guid.NewGuid().ToString("N"); 1519 } 1520 1521 /*base settings*/ 1522 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1523 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1524 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1525 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1526 if (settings.Required) { attributes.Add("required", "true"); } 1527 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1528 /*end*/ 1529 1530 attributes.Add("type", "radio"); 1531 if (settings.Checked) { attributes.Add("checked", "true"); } 1532 settings.CssClass = "form__control " + settings.CssClass; 1533 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1534 1535 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1536 1537 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1538 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1539 @if (!string.IsNullOrEmpty(settings.Label)) 1540 { 1541 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1542 } 1543 @if (!string.IsNullOrEmpty(settings.HelpText)) 1544 { 1545 <small class="form__help-text">@settings.HelpText</small> 1546 } 1547 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1548 </div> 1549 } 1550 @using System.Reflection 1551 @using Dynamicweb.Rapido.Blocks.Components.General 1552 @using Dynamicweb.Rapido.Blocks.Components 1553 1554 1555 @* Component *@ 1556 1557 @helper RenderRadioButtonListField(RadioButtonListField settings) 1558 { 1559 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1560 1561 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1562 @if (!string.IsNullOrEmpty(settings.Label)) 1563 { 1564 <label>@settings.Label</label> 1565 } 1566 @if (!string.IsNullOrEmpty(settings.HelpText)) 1567 { 1568 <small class="form__help-text">@settings.HelpText</small> 1569 } 1570 1571 @foreach (var item in settings.Options) 1572 { 1573 if (settings.Required) 1574 { 1575 item.Required = true; 1576 } 1577 if (settings.Disabled) 1578 { 1579 item.Disabled = true; 1580 } 1581 if (!string.IsNullOrEmpty(settings.Name)) 1582 { 1583 item.Name = settings.Name; 1584 } 1585 if (settings.Value != null && settings.Value == item.Value) 1586 { 1587 item.Checked = true; 1588 } 1589 if (!string.IsNullOrEmpty(settings.OnClick)) 1590 { 1591 item.OnClick += settings.OnClick; 1592 } 1593 if (!string.IsNullOrEmpty(settings.OnChange)) 1594 { 1595 item.OnChange += settings.OnChange; 1596 } 1597 if (!string.IsNullOrEmpty(settings.CssClass)) 1598 { 1599 item.CssClass += settings.CssClass; 1600 } 1601 @Render(item) 1602 } 1603 1604 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1605 </div> 1606 } 1607 @using System.Reflection 1608 @using Dynamicweb.Rapido.Blocks.Components.General 1609 @using Dynamicweb.Rapido.Blocks.Components 1610 1611 1612 @* Component *@ 1613 1614 @helper RenderNotificationMessage(NotificationMessage settings) 1615 { 1616 if (!string.IsNullOrEmpty(settings.Message)) 1617 { 1618 var attributes = new Dictionary<string, string>(); 1619 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1620 1621 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1622 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1623 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1624 1625 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1626 @if (settings.Icon != null) { 1627 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1628 @Render(settings.Icon) 1629 } else { 1630 @settings.Message 1631 } 1632 </div> 1633 } 1634 } 1635 @using Dynamicweb.Rapido.Blocks.Components.General 1636 1637 1638 @* Component *@ 1639 1640 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1641 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1642 1643 <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> 1644 @if (settings.SubBlocks != null) { 1645 @RenderBlockList(settings.SubBlocks) 1646 } 1647 </div> 1648 } 1649 @using System.Reflection 1650 @using Dynamicweb.Rapido.Blocks.Components.General 1651 @using Dynamicweb.Rapido.Blocks.Components 1652 @using System.Text.RegularExpressions 1653 1654 1655 @* Component *@ 1656 1657 @helper RenderSticker(Sticker settings) { 1658 if (!String.IsNullOrEmpty(settings.Title)) { 1659 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1660 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1661 1662 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1663 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1664 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1665 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1666 optionalAttributes.Add("style", styleTag); 1667 } 1668 1669 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1670 } 1671 } 1672 1673 @using System.Reflection 1674 @using Dynamicweb.Rapido.Blocks.Components.General 1675 @using Dynamicweb.Rapido.Blocks.Components 1676 1677 1678 @* Component *@ 1679 1680 @helper RenderStickersCollection(StickersCollection settings) 1681 { 1682 if (settings.Stickers.Count > 0) 1683 { 1684 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1685 1686 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1687 @foreach (Sticker sticker in settings.Stickers) 1688 { 1689 @Render(sticker) 1690 } 1691 </div> 1692 } 1693 } 1694 1695 @using Dynamicweb.Rapido.Blocks.Components.General 1696 1697 1698 @* Component *@ 1699 1700 @helper RenderForm(Form settings) { 1701 if (settings != null) 1702 { 1703 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1704 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1705 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1706 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1707 var enctypes = new Dictionary<string, string> 1708 { 1709 { "multipart", "multipart/form-data" }, 1710 { "text", "text/plain" }, 1711 { "application", "application/x-www-form-urlencoded" } 1712 }; 1713 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1714 optionalAttributes.Add("method", settings.Method.ToString()); 1715 1716 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1717 { 1718 @settings.FormStartMarkup 1719 } 1720 else 1721 { 1722 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1723 } 1724 1725 foreach (var field in settings.GetFields()) 1726 { 1727 @Render(field) 1728 } 1729 1730 @:</form> 1731 } 1732 } 1733 @using System.Reflection 1734 @using Dynamicweb.Rapido.Blocks.Components.General 1735 @using Dynamicweb.Rapido.Blocks.Components 1736 1737 1738 @* Component *@ 1739 1740 @helper RenderText(Text settings) 1741 { 1742 @settings.Content 1743 } 1744 @using System.Reflection 1745 @using Dynamicweb.Rapido.Blocks.Components.General 1746 @using Dynamicweb.Rapido.Blocks.Components 1747 1748 1749 @* Component *@ 1750 1751 @helper RenderContentModule(ContentModule settings) { 1752 if (!string.IsNullOrEmpty(settings.Content)) 1753 { 1754 @settings.Content 1755 } 1756 } 1757 @using System.Reflection 1758 @using Dynamicweb.Rapido.Blocks.Components.General 1759 @using Dynamicweb.Rapido.Blocks.Components 1760 1761 1762 @* Component *@ 1763 1764 @helper RenderModal(Modal settings) { 1765 if (settings != null) 1766 { 1767 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1768 1769 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1770 1771 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1772 1773 <div class="modal-container"> 1774 @if (!settings.DisableDarkOverlay) 1775 { 1776 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1777 } 1778 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1779 @if (settings.Heading != null) 1780 { 1781 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1782 { 1783 <div class="modal__header"> 1784 @Render(settings.Heading) 1785 </div> 1786 } 1787 } 1788 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1789 @if (!string.IsNullOrEmpty(settings.BodyText)) 1790 { 1791 @settings.BodyText 1792 } 1793 @if (settings.BodyTemplate != null) 1794 { 1795 @settings.BodyTemplate 1796 } 1797 @{ 1798 var actions = settings.GetActions(); 1799 } 1800 </div> 1801 @if (actions.Length > 0) 1802 { 1803 <div class="modal__footer"> 1804 @foreach (var action in actions) 1805 { 1806 if (Pageview.Device.ToString() != "Mobile") { 1807 action.CssClass += " u-no-margin"; 1808 } else { 1809 action.CssClass += " u-full-width u-margin-bottom"; 1810 } 1811 1812 @Render(action) 1813 } 1814 </div> 1815 } 1816 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1817 </div> 1818 </div> 1819 } 1820 } 1821 @using Dynamicweb.Rapido.Blocks.Components.General 1822 1823 @* Component *@ 1824 1825 @helper RenderMediaListItem(MediaListItem settings) 1826 { 1827 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1828 @if (!string.IsNullOrEmpty(settings.Label)) 1829 { 1830 if (!string.IsNullOrEmpty(settings.Link)) 1831 { 1832 @Render(new Link 1833 { 1834 Href = settings.Link, 1835 CssClass = "media-list-item__sticker dw-mod", 1836 ButtonLayout = ButtonLayout.None, 1837 Title = settings.Label, 1838 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1839 }) 1840 } 1841 else if (!string.IsNullOrEmpty(settings.OnClick)) 1842 { 1843 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1844 <span class="u-uppercase">@settings.Label</span> 1845 </span> 1846 } 1847 else 1848 { 1849 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1850 <span class="u-uppercase">@settings.Label</span> 1851 </span> 1852 } 1853 } 1854 <div class="media-list-item__wrap"> 1855 <div class="media-list-item__info dw-mod"> 1856 <div class="media-list-item__header dw-mod"> 1857 @if (!string.IsNullOrEmpty(settings.Title)) 1858 { 1859 if (!string.IsNullOrEmpty(settings.Link)) 1860 { 1861 @Render(new Link 1862 { 1863 Href = settings.Link, 1864 CssClass = "media-list-item__name dw-mod", 1865 ButtonLayout = ButtonLayout.None, 1866 Title = settings.Title, 1867 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1868 }) 1869 } 1870 else if (!string.IsNullOrEmpty(settings.OnClick)) 1871 { 1872 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1873 } 1874 else 1875 { 1876 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1877 } 1878 } 1879 1880 @if (!string.IsNullOrEmpty(settings.Status)) 1881 { 1882 <div class="media-list-item__state dw-mod">@settings.Status</div> 1883 } 1884 </div> 1885 @{ 1886 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1887 } 1888 1889 @Render(settings.InfoTable) 1890 </div> 1891 <div class="media-list-item__actions dw-mod"> 1892 <div class="media-list-item__actions-list dw-mod"> 1893 @{ 1894 var actions = settings.GetActions(); 1895 1896 foreach (ButtonBase action in actions) 1897 { 1898 action.ButtonLayout = ButtonLayout.None; 1899 action.CssClass += " media-list-item__action link"; 1900 1901 @Render(action) 1902 } 1903 } 1904 </div> 1905 1906 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1907 { 1908 settings.SelectButton.CssClass += " u-no-margin"; 1909 1910 <div class="media-list-item__action-button"> 1911 @Render(settings.SelectButton) 1912 </div> 1913 } 1914 </div> 1915 </div> 1916 </div> 1917 } 1918 @using Dynamicweb.Rapido.Blocks.Components.General 1919 @using Dynamicweb.Rapido.Blocks.Components 1920 1921 @helper RenderTable(Table settings) 1922 { 1923 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1924 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1925 1926 var enumToClasses = new Dictionary<TableDesign, string> 1927 { 1928 { TableDesign.Clean, "table--clean" }, 1929 { TableDesign.Bordered, "table--bordered" }, 1930 { TableDesign.Striped, "table--striped" }, 1931 { TableDesign.Hover, "table--hover" }, 1932 { TableDesign.Compact, "table--compact" }, 1933 { TableDesign.Condensed, "table--condensed" }, 1934 { TableDesign.NoTopBorder, "table--no-top-border" } 1935 }; 1936 string tableDesignClass = ""; 1937 if (settings.Design != TableDesign.None) 1938 { 1939 tableDesignClass = enumToClasses[settings.Design]; 1940 } 1941 1942 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1943 1944 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1945 1946 <table @ComponentMethods.AddAttributes(resultAttributes)> 1947 @if (settings.Header != null) 1948 { 1949 <thead> 1950 @Render(settings.Header) 1951 </thead> 1952 } 1953 <tbody> 1954 @foreach (var row in settings.Rows) 1955 { 1956 @Render(row) 1957 } 1958 </tbody> 1959 @if (settings.Footer != null) 1960 { 1961 <tfoot> 1962 @Render(settings.Footer) 1963 </tfoot> 1964 } 1965 </table> 1966 } 1967 @using Dynamicweb.Rapido.Blocks.Components.General 1968 @using Dynamicweb.Rapido.Blocks.Components 1969 1970 @helper RenderTableRow(TableRow settings) 1971 { 1972 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1973 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1974 1975 var enumToClasses = new Dictionary<TableRowDesign, string> 1976 { 1977 { TableRowDesign.NoBorder, "table__row--no-border" }, 1978 { TableRowDesign.Border, "table__row--border" }, 1979 { TableRowDesign.TopBorder, "table__row--top-line" }, 1980 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1981 { TableRowDesign.Solid, "table__row--solid" } 1982 }; 1983 1984 string tableRowDesignClass = ""; 1985 if (settings.Design != TableRowDesign.None) 1986 { 1987 tableRowDesignClass = enumToClasses[settings.Design]; 1988 } 1989 1990 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1991 1992 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1993 1994 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1995 @foreach (var cell in settings.Cells) 1996 { 1997 if (settings.IsHeaderRow) 1998 { 1999 cell.IsHeader = true; 2000 } 2001 @Render(cell) 2002 } 2003 </tr> 2004 } 2005 @using Dynamicweb.Rapido.Blocks.Components.General 2006 @using Dynamicweb.Rapido.Blocks.Components 2007 @using Dynamicweb.Core 2008 2009 @helper RenderTableCell(TableCell settings) 2010 { 2011 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2012 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2013 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2014 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2015 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2016 2017 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2018 2019 string tagName = settings.IsHeader ? "th" : "td"; 2020 2021 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2022 @settings.Content 2023 @("</" + tagName + ">"); 2024 } 2025 @using System.Linq 2026 @using Dynamicweb.Rapido.Blocks.Components.General 2027 2028 @* Component *@ 2029 2030 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2031 { 2032 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2033 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2034 2035 if (settings.NumberOfPages > 1) 2036 { 2037 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2038 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2039 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2040 2041 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2042 @if (settings.ShowPagingInfo) 2043 { 2044 <div class="pager__info dw-mod"> 2045 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2046 </div> 2047 } 2048 <ul class="pager__list dw-mod"> 2049 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2050 { 2051 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2052 } 2053 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2054 { 2055 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2056 } 2057 @if (settings.GetPages().Any()) 2058 { 2059 foreach (var page in settings.GetPages()) 2060 { 2061 @Render(page) 2062 } 2063 } 2064 else 2065 { 2066 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2067 { 2068 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2069 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2070 } 2071 } 2072 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2073 { 2074 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2075 } 2076 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2077 { 2078 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2079 } 2080 </ul> 2081 </div> 2082 } 2083 } 2084 2085 @helper RenderPaginationItem(PaginationItem settings) 2086 { 2087 if (settings.Icon == null) 2088 { 2089 settings.Icon = new Icon(); 2090 } 2091 2092 settings.Icon.Label = settings.Label; 2093 <li class="pager__btn dw-mod"> 2094 @if (settings.IsActive) 2095 { 2096 <span class="pager__num pager__num--current dw-mod"> 2097 @Render(settings.Icon) 2098 </span> 2099 } 2100 else 2101 { 2102 <a href="@settings.Link" class="pager__num dw-mod"> 2103 @Render(settings.Icon) 2104 </a> 2105 } 2106 </li> 2107 } 2108 2109 2110 @using Dynamicweb.Rapido.Blocks.Components.General 2111 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2112 2113 2114 2115 2116 2117 @functions { 2118 public string GenerateRgba(string color, string opacity) 2119 { 2120 color = color.Replace("#", ""); 2121 if (color.Length == 6) { 2122 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 2123 } else { 2124 return Convert.ToInt16(color).ToString(); 2125 } 2126 } 2127 } 2128 2129 @{ 2130 string link = !string.IsNullOrEmpty(Model.Item.GetString("Link")) ? Model.Item.GetString("Link") : ""; 2131 string linkTarget = link.Contains("http") ? "_blank" : "_self"; 2132 } 2133 2134 @if (!string.IsNullOrEmpty(link)) { 2135 <a href="@link" target="@linkTarget" class="u-overlay">&nbsp;</a> 2136 @RenderTheContent() 2137 } else { 2138 @RenderTheContent() 2139 } 2140 2141 @helper RenderTheContent(){ 2142 var colorService = new ColorSwatchService(); 2143 2144 string innerPadding = Model.Item.GetList("Padding") != null ? " padding-size-" + Model.Item.GetList("Padding").SelectedValue.ToLower() : ""; 2145 innerPadding += Model.Item.GetList("PaddingPosition") != null ? " padding-position-" + Model.Item.GetList("PaddingPosition").SelectedValue.ToLower() : ""; 2146 string outerMargin = Model.Item.GetList("Margin") != null ? " margin-" + Model.Item.GetList("Margin").SelectedValue.ToLower() : ""; 2147 string outerMarginPosition = Model.Item.GetList("MarginPosition") != null ? " margin-position-" + Model.Item.GetList("MarginPosition").SelectedValue.ToLower() : ""; 2148 2149 string cardBackgroundColor = Model.Item.GetString("CardBackgroundColor") != null ? Model.Item.GetString("CardBackgroundColor") : ""; 2150 cardBackgroundColor = !cardBackgroundColor.Contains("#") ? colorService.GetHexColor(Pageview.AreaID, cardBackgroundColor) : cardBackgroundColor; 2151 string styles = "background-color: " + cardBackgroundColor + ";"; 2152 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) { 2153 int cropMode = !string.IsNullOrEmpty(Convert.ToString(Model.Item.GetList("ImageCrop"))) ? Convert.ToInt32(Model.Item.GetList("ImageCrop").SelectedValue) : 0; 2154 2155 Image image = new Image 2156 { 2157 Path = Model.Item.GetFile("Image") != null ? Model.Item.GetFile("Image").Path : "", 2158 CssClass = "background-image__cover", 2159 ImageDefault = new ImageSettings 2160 { 2161 Crop = cropMode, 2162 Height = 845, 2163 Width = 1920 2164 }, 2165 ImageMedium = new ImageSettings 2166 { 2167 Crop = cropMode, 2168 Height = 450, 2169 Width = 1024 2170 }, 2171 ImageSmall = new ImageSettings 2172 { 2173 Crop = cropMode, 2174 Height = 544, 2175 Width = 640 2176 } 2177 }; 2178 2179 image.FilterPrimary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2180 image.FilterSecondary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2181 2182 if (!string.IsNullOrEmpty(Model.Item.GetString("ColorForTheFilter"))) { 2183 image.FilterColor = Model.Item.GetString("ColorForTheFilter").StartsWith("#") ? GenerateRgba(Model.Item.GetString("ColorForTheFilter"), "0.3") : ""; 2184 } 2185 2186 <div class="background-image dw-mod"> 2187 <div class="background-image__wrapper dw-mod"> 2188 @Render(image) 2189 </div> 2190 </div> 2191 } 2192 2193 <div class="content-row__item__body @innerPadding @outerMargin @outerMarginPosition card-paragraph dw-mod" style="@styles"> 2194 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Text"))) { 2195 if (!Model.Item.GetBoolean("HideTitle")) { 2196 @Render(new Heading { Title = Model.Item.GetString("Title"), CssClass = "u-no-margin", Level = 2 }) 2197 } 2198 @Render(new Text { Content = Model.Item.GetString("Text") }) 2199 } 2200 2201 @if (!string.IsNullOrEmpty(Model.Item.GetItem("ButtonOne").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonTwo").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonThree").GetString("Title"))) { 2202 <div> 2203 @ParagraphButton(Model.Item.GetItem("ButtonOne")) 2204 @ParagraphButton(Model.Item.GetItem("ButtonTwo")) 2205 @ParagraphButton(Model.Item.GetItem("ButtonThree")) 2206 </div> 2207 } 2208 </div> 2209 } 2210 2211 2212 @helper ParagraphButton(ItemViewModel item) { 2213 if (item != null) { 2214 if (!string.IsNullOrEmpty(item.GetString("Title"))) { 2215 Button button = new Button { 2216 Title = item.GetString("Title"), 2217 Href = item.GetString("Link"), 2218 CssClass = "u-no-margin", 2219 ButtonLayout = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("Layout").SelectedValue[0]) + item.GetList("Layout").SelectedValue.Substring(1)) 2220 }; 2221 2222 if (!string.IsNullOrEmpty(item.GetString("Icon"))) { 2223 button.Icon = new Icon { 2224 CssClass = item.GetString("Icon") 2225 }; 2226 } 2227 2228 @Render(button) 2229 } 2230 } 2231 } 2232 2233 2234 2235 2236