Vi designar och utvecklar köksfläktar

Thermex har sitt huvudkontor i Hjørring, norr om Limfjorden, där det finns hav på alla sidor är högt i tak och gott om frisk luft. Det är med inspiration från dessa ramverk som vi designar och utvecklar våra produkter.

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_3d17c237f02b45fb9168be3d2dae3286.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2215
   at CompiledRazorTemplates.Dynamic.RazorEngine_3d17c237f02b45fb9168be3d2dae3286.Execute() in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2152
   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 if (settings.ExtraAttributes == null) 898 { 899 settings.ExtraAttributes = new Dictionary<string, string>(); 900 } 901 settings.ExtraAttributes.Add("autocomplete","off"); 902 var textField = new TextField { 903 Name = settings.Name, 904 Id = settings.Id, 905 Label = settings.Label, 906 HelpText = settings.HelpText, 907 Value = settings.Value, 908 Disabled = settings.Disabled, 909 Required = settings.Required, 910 ErrorMessage = settings.ErrorMessage, 911 CssClass = settings.CssClass, 912 WrapperCssClass = settings.WrapperCssClass, 913 OnChange = settings.OnChange, 914 OnClick = settings.OnClick, 915 Link = settings.Link, 916 ExtraAttributes = settings.ExtraAttributes, 917 // 918 Placeholder = settings.Placeholder 919 }; 920 921 @Render(textField) 922 923 List<string> jsAttributes = new List<string>(); 924 925 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 926 927 if (!string.IsNullOrEmpty(settings.DateFormat)) 928 { 929 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 930 } 931 if (!string.IsNullOrEmpty(settings.MinDate)) 932 { 933 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 934 } 935 if (!string.IsNullOrEmpty(settings.MaxDate)) 936 { 937 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 938 } 939 if (settings.IsInline) 940 { 941 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 942 } 943 if (settings.EnableTime) 944 { 945 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 946 } 947 if (settings.EnableWeekNumbers) 948 { 949 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 950 } 951 952 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 953 954 <script> 955 document.addEventListener( "DOMContentLoaded", function () { 956 flatpickr("#@textField.Id", { 957 onReady: function(selectedDates, dateStr, instance) { 958 instance.input.readOnly = false; 959 }, 960 onOpen: function(selectedDates, dateStr, instance) { 961 instance.input.readOnly = true; 962 }, 963 onClose: function(selectedDates, dateStr, instance) { 964 instance.input.readOnly = false; 965 //instance.input.blur(); 966 }, 967 @string.Join(",", jsAttributes) 968 } ) 969 } ); 970 </script> 971 } 972 @using System.Reflection 973 @using Dynamicweb.Rapido.Blocks.Components.General 974 @using Dynamicweb.Rapido.Blocks.Components 975 976 @* Component *@ 977 978 @helper RenderTextField(TextField settings) 979 { 980 var attributes = new Dictionary<string, string>(); 981 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 982 { 983 settings.Id = Guid.NewGuid().ToString("N"); 984 } 985 986 /*base settings*/ 987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 988 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 989 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 990 if (settings.Disabled) { attributes.Add("disabled", "true"); } 991 if (settings.Required) { attributes.Add("required", "true"); } 992 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 993 /*end*/ 994 995 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 996 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 997 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 998 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 999 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1000 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1001 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1002 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1003 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1004 1005 settings.CssClass = "u-full-width " + settings.CssClass; 1006 1007 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1008 1009 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1010 1011 string noMargin = "u-no-margin"; 1012 if (!settings.ReadOnly) { 1013 noMargin = ""; 1014 } 1015 1016 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1017 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1018 { 1019 <div class="u-full-width"> 1020 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1021 @if (settings.Link != null) { 1022 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1023 1024 <div class="u-pull--right"> 1025 @Render(settings.Link) 1026 </div> 1027 } 1028 </div> 1029 1030 } 1031 1032 @if (!string.IsNullOrEmpty(settings.HelpText)) 1033 { 1034 <small class="form__help-text">@settings.HelpText</small> 1035 } 1036 1037 @if (settings.ActionButton != null) 1038 { 1039 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1040 <div class="form__field-combi u-no-margin dw-mod"> 1041 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1042 @Render(settings.ActionButton) 1043 </div> 1044 } 1045 else 1046 { 1047 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1048 } 1049 1050 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1051 </div> 1052 } 1053 @using System.Reflection 1054 @using Dynamicweb.Rapido.Blocks.Components.General 1055 @using Dynamicweb.Rapido.Blocks.Components 1056 1057 @* Component *@ 1058 1059 @helper RenderNumberField(NumberField settings) 1060 { 1061 var attributes = new Dictionary<string, string>(); 1062 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1063 { 1064 settings.Id = Guid.NewGuid().ToString("N"); 1065 } 1066 1067 /*base settings*/ 1068 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1069 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1070 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1071 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1072 if (settings.Required) { attributes.Add("required", "true"); } 1073 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1074 /*end*/ 1075 1076 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1077 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1078 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1079 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1080 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1081 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1082 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1083 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1084 attributes.Add("type", "number"); 1085 1086 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1087 1088 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1089 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1090 { 1091 <div class="u-full-width"> 1092 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1093 @if (settings.Link != null) { 1094 <div class="u-pull--right"> 1095 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1096 @Render(settings.Link) 1097 </div> 1098 } 1099 </div> 1100 1101 } 1102 1103 @if (!string.IsNullOrEmpty(settings.HelpText)) 1104 { 1105 <small class="form__help-text">@settings.HelpText</small> 1106 } 1107 1108 @if (settings.ActionButton != null) 1109 { 1110 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1111 <div class="form__field-combi u-no-margin dw-mod"> 1112 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1113 @Render(settings.ActionButton) 1114 </div> 1115 } 1116 else 1117 { 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 </div> 1121 } 1122 1123 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1124 </div> 1125 } 1126 @using System.Reflection 1127 @using Dynamicweb.Rapido.Blocks.Components.General 1128 @using Dynamicweb.Rapido.Blocks.Components 1129 1130 1131 @* Component *@ 1132 1133 @helper RenderTextareaField(TextareaField settings) 1134 { 1135 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1136 string id = settings.Id; 1137 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1138 { 1139 id = Guid.NewGuid().ToString("N"); 1140 } 1141 1142 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1143 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1144 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1145 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1146 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1147 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1148 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1149 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1150 if (settings.Required) { attributes.Add("required", "true"); } 1151 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1152 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1153 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1154 attributes.Add("name", settings.Name); 1155 1156 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1157 1158 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1159 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1160 { 1161 <div class="u-full-width"> 1162 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1163 @if (settings.Link != null) { 1164 <div class="u-pull--right"> 1165 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1166 @Render(settings.Link) 1167 </div> 1168 } 1169 </div> 1170 } 1171 1172 @if (!string.IsNullOrEmpty(settings.HelpText)) 1173 { 1174 <small class="form__help-text">@settings.HelpText</small> 1175 } 1176 1177 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1178 1179 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1180 </div> 1181 } 1182 @using System.Reflection 1183 @using Dynamicweb.Rapido.Blocks.Components.General 1184 @using Dynamicweb.Rapido.Blocks.Components 1185 1186 1187 @* Component *@ 1188 1189 @helper RenderHiddenField(HiddenField settings) { 1190 var attributes = new Dictionary<string, string>(); 1191 attributes.Add("type", "hidden"); 1192 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1193 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1195 1196 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1197 } 1198 @using System.Reflection 1199 @using Dynamicweb.Rapido.Blocks.Components.General 1200 @using Dynamicweb.Rapido.Blocks.Components 1201 1202 @* Component *@ 1203 1204 @helper RenderCheckboxField(CheckboxField settings) 1205 { 1206 var attributes = new Dictionary<string, string>(); 1207 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1208 { 1209 settings.Id = Guid.NewGuid().ToString("N"); 1210 } 1211 1212 /*base settings*/ 1213 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1214 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1215 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1216 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1217 if (settings.Required) { attributes.Add("required", "true"); } 1218 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1219 /*end*/ 1220 1221 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1222 1223 attributes.Add("type", "checkbox"); 1224 if (settings.Checked) { attributes.Add("checked", "true"); } 1225 settings.CssClass = "form__control " + settings.CssClass; 1226 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1227 1228 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1229 1230 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1231 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1232 @if (!string.IsNullOrEmpty(settings.Label)) 1233 { 1234 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1235 } 1236 1237 @if (settings.Link != null) { 1238 <span> 1239 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1240 @Render(settings.Link) 1241 </span> 1242 } 1243 1244 @if (!string.IsNullOrEmpty(settings.HelpText)) 1245 { 1246 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1247 } 1248 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1249 </div> 1250 } 1251 @using System.Reflection 1252 @using Dynamicweb.Rapido.Blocks.Components.General 1253 @using Dynamicweb.Rapido.Blocks.Components 1254 1255 1256 @* Component *@ 1257 1258 @helper RenderCheckboxListField(CheckboxListField settings) 1259 { 1260 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1261 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1262 { 1263 <div class="u-full-width"> 1264 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1265 @if (settings.Link != null) { 1266 <div class="u-pull--right"> 1267 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1268 @Render(settings.Link) 1269 </div> 1270 } 1271 </div> 1272 1273 } 1274 1275 <div class="u-pull--left"> 1276 @if (!string.IsNullOrEmpty(settings.HelpText)) 1277 { 1278 <small class="form__help-text">@settings.HelpText</small> 1279 } 1280 1281 @foreach (var item in settings.Options) 1282 { 1283 if (settings.Required) 1284 { 1285 item.Required = true; 1286 } 1287 if (settings.Disabled) 1288 { 1289 item.Disabled = true; 1290 } 1291 if (!string.IsNullOrEmpty(settings.Name)) 1292 { 1293 item.Name = settings.Name; 1294 } 1295 if (!string.IsNullOrEmpty(settings.CssClass)) 1296 { 1297 item.CssClass += settings.CssClass; 1298 } 1299 1300 /* value is not supported */ 1301 1302 if (!string.IsNullOrEmpty(settings.OnClick)) 1303 { 1304 item.OnClick += settings.OnClick; 1305 } 1306 if (!string.IsNullOrEmpty(settings.OnChange)) 1307 { 1308 item.OnChange += settings.OnChange; 1309 } 1310 @Render(item) 1311 } 1312 1313 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1314 </div> 1315 1316 </div> 1317 } 1318 @using Dynamicweb.Rapido.Blocks.Components.General 1319 1320 @* Component *@ 1321 1322 @helper RenderSearch(Search settings) 1323 { 1324 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1325 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1326 1327 if (string.IsNullOrEmpty(settings.Id)) 1328 { 1329 settings.Id = Guid.NewGuid().ToString("N"); 1330 } 1331 1332 var resultAttributes = new Dictionary<string, string>(); 1333 1334 if (settings.PageSize != 0) 1335 { 1336 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1337 } 1338 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1339 { 1340 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1341 if (!string.IsNullOrEmpty(groupValue)) 1342 { 1343 resultAttributes.Add("data-selected-group", groupValue); 1344 } 1345 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1346 { 1347 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1348 } 1349 } 1350 resultAttributes.Add("data-force-init", "true"); 1351 if (settings.GoToFirstSearchResultOnEnter) 1352 { 1353 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1354 } 1355 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1356 { 1357 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1358 } 1359 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1360 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1361 1362 if (settings.SecondSearchData != null) 1363 { 1364 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1365 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1366 } 1367 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1368 { 1369 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1370 } 1371 1372 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1373 1374 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1375 1376 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1377 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1378 { 1379 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1380 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1381 } 1382 1383 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1384 1385 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1386 @if (settings.SecondSearchData != null) 1387 { 1388 <div class="search__column search__column--products dw-mod"> 1389 <div class="search__column-header dw-mod">@Translate("Products")</div> 1390 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1391 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1392 { 1393 @Render(new Link { 1394 Title = Translate("View all"), 1395 CssClass = "js-view-all-button u-margin", 1396 Href = settings.SearchData.ResultsPageUrl 1397 }); 1398 } 1399 </div> 1400 <div class="search__column search__column--pages dw-mod"> 1401 <div class="search__column-header">@Translate("Pages")</div> 1402 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1403 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1404 { 1405 @Render(new Link 1406 { 1407 Title = Translate("View all"), 1408 CssClass = "js-view-all-button u-margin", 1409 Href = settings.SecondSearchData.ResultsPageUrl 1410 }); 1411 } 1412 </div> 1413 } 1414 else 1415 { 1416 <div class="search__column search__column--only dw-mod"> 1417 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1418 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1419 { 1420 @Render(new Link { 1421 Title = Translate("View all"), 1422 CssClass = "js-view-all-button u-margin", 1423 Href = settings.SearchData.ResultsPageUrl 1424 }); 1425 } 1426 </div> 1427 } 1428 </div> 1429 1430 @if (settings.SearchButton != null) 1431 { 1432 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1433 if (settings.RenderDefaultSearchIcon) 1434 { 1435 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1436 } 1437 @Render(settings.SearchButton); 1438 } 1439 </div> 1440 } 1441 @using System.Reflection 1442 @using Dynamicweb.Rapido.Blocks.Components.General 1443 @using Dynamicweb.Rapido.Blocks.Components 1444 1445 1446 @* Component *@ 1447 1448 @helper RenderSelectField(SelectField settings) 1449 { 1450 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1451 { 1452 settings.Id = Guid.NewGuid().ToString("N"); 1453 } 1454 1455 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1456 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1457 { 1458 <div class="u-full-width"> 1459 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1460 @if (settings.Link != null) { 1461 <div class="u-pull--right"> 1462 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1463 @Render(settings.Link) 1464 </div> 1465 } 1466 </div> 1467 } 1468 1469 @if (!string.IsNullOrEmpty(settings.HelpText)) 1470 { 1471 <small class="form__help-text">@settings.HelpText</small> 1472 } 1473 1474 @if (settings.ActionButton != null) 1475 { 1476 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1477 <div class="form__field-combi u-no-margin dw-mod"> 1478 @RenderSelectBase(settings) 1479 @Render(settings.ActionButton) 1480 </div> 1481 } 1482 else 1483 { 1484 @RenderSelectBase(settings) 1485 } 1486 1487 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1488 </div> 1489 } 1490 1491 @helper RenderSelectBase(SelectField settings) 1492 { 1493 var attributes = new Dictionary<string, string>(); 1494 1495 /*base settings*/ 1496 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1497 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1498 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1499 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1500 if (settings.Required) { attributes.Add("required", "true"); } 1501 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1502 /*end*/ 1503 1504 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1505 1506 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1507 @if (settings.Default != null) 1508 { 1509 @Render(settings.Default) 1510 } 1511 1512 @foreach (var item in settings.Options) 1513 { 1514 if (settings.Value != null) { 1515 item.Checked = item.Value == settings.Value; 1516 } 1517 @Render(item) 1518 } 1519 </select> 1520 } 1521 @using System.Reflection 1522 @using Dynamicweb.Rapido.Blocks.Components.General 1523 @using Dynamicweb.Rapido.Blocks.Components 1524 1525 @* Component *@ 1526 1527 @helper RenderRadioButtonField(RadioButtonField settings) 1528 { 1529 var attributes = new Dictionary<string, string>(); 1530 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1531 { 1532 settings.Id = Guid.NewGuid().ToString("N"); 1533 } 1534 1535 /*base settings*/ 1536 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1537 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1538 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1539 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1540 if (settings.Required) { attributes.Add("required", "true"); } 1541 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1542 /*end*/ 1543 1544 attributes.Add("type", "radio"); 1545 if (settings.Checked) { attributes.Add("checked", "true"); } 1546 settings.CssClass = "form__control " + settings.CssClass; 1547 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1548 1549 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1550 1551 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1552 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1553 @if (!string.IsNullOrEmpty(settings.Label)) 1554 { 1555 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1556 } 1557 @if (!string.IsNullOrEmpty(settings.HelpText)) 1558 { 1559 <small class="form__help-text">@settings.HelpText</small> 1560 } 1561 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1562 </div> 1563 } 1564 @using System.Reflection 1565 @using Dynamicweb.Rapido.Blocks.Components.General 1566 @using Dynamicweb.Rapido.Blocks.Components 1567 1568 1569 @* Component *@ 1570 1571 @helper RenderRadioButtonListField(RadioButtonListField settings) 1572 { 1573 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1574 1575 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1576 @if (!string.IsNullOrEmpty(settings.Label)) 1577 { 1578 <label>@settings.Label</label> 1579 } 1580 @if (!string.IsNullOrEmpty(settings.HelpText)) 1581 { 1582 <small class="form__help-text">@settings.HelpText</small> 1583 } 1584 1585 @foreach (var item in settings.Options) 1586 { 1587 if (settings.Required) 1588 { 1589 item.Required = true; 1590 } 1591 if (settings.Disabled) 1592 { 1593 item.Disabled = true; 1594 } 1595 if (!string.IsNullOrEmpty(settings.Name)) 1596 { 1597 item.Name = settings.Name; 1598 } 1599 if (settings.Value != null && settings.Value == item.Value) 1600 { 1601 item.Checked = true; 1602 } 1603 if (!string.IsNullOrEmpty(settings.OnClick)) 1604 { 1605 item.OnClick += settings.OnClick; 1606 } 1607 if (!string.IsNullOrEmpty(settings.OnChange)) 1608 { 1609 item.OnChange += settings.OnChange; 1610 } 1611 if (!string.IsNullOrEmpty(settings.CssClass)) 1612 { 1613 item.CssClass += settings.CssClass; 1614 } 1615 @Render(item) 1616 } 1617 1618 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1619 </div> 1620 } 1621 @using System.Reflection 1622 @using Dynamicweb.Rapido.Blocks.Components.General 1623 @using Dynamicweb.Rapido.Blocks.Components 1624 1625 1626 @* Component *@ 1627 1628 @helper RenderNotificationMessage(NotificationMessage settings) 1629 { 1630 if (!string.IsNullOrEmpty(settings.Message)) 1631 { 1632 var attributes = new Dictionary<string, string>(); 1633 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1634 1635 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1636 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1637 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1638 1639 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1640 @if (settings.Icon != null) { 1641 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1642 @Render(settings.Icon) 1643 } else { 1644 @settings.Message 1645 } 1646 </div> 1647 } 1648 } 1649 @using Dynamicweb.Rapido.Blocks.Components.General 1650 1651 1652 @* Component *@ 1653 1654 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1655 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1656 1657 <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> 1658 @if (settings.SubBlocks != null) { 1659 @RenderBlockList(settings.SubBlocks) 1660 } 1661 </div> 1662 } 1663 @using System.Reflection 1664 @using Dynamicweb.Rapido.Blocks.Components.General 1665 @using Dynamicweb.Rapido.Blocks.Components 1666 @using System.Text.RegularExpressions 1667 1668 1669 @* Component *@ 1670 1671 @helper RenderSticker(Sticker settings) { 1672 if (!String.IsNullOrEmpty(settings.Title)) { 1673 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1674 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1675 1676 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1677 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1678 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1679 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1680 optionalAttributes.Add("style", styleTag); 1681 } 1682 1683 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1684 } 1685 } 1686 1687 @using System.Reflection 1688 @using Dynamicweb.Rapido.Blocks.Components.General 1689 @using Dynamicweb.Rapido.Blocks.Components 1690 1691 1692 @* Component *@ 1693 1694 @helper RenderStickersCollection(StickersCollection settings) 1695 { 1696 if (settings.Stickers.Count > 0) 1697 { 1698 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1699 1700 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1701 @foreach (Sticker sticker in settings.Stickers) 1702 { 1703 @Render(sticker) 1704 } 1705 </div> 1706 } 1707 } 1708 1709 @using Dynamicweb.Rapido.Blocks.Components.General 1710 1711 1712 @* Component *@ 1713 1714 @helper RenderForm(Form settings) { 1715 if (settings != null) 1716 { 1717 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1718 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1719 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1720 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1721 var enctypes = new Dictionary<string, string> 1722 { 1723 { "multipart", "multipart/form-data" }, 1724 { "text", "text/plain" }, 1725 { "application", "application/x-www-form-urlencoded" } 1726 }; 1727 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1728 optionalAttributes.Add("method", settings.Method.ToString()); 1729 1730 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1731 { 1732 @settings.FormStartMarkup 1733 } 1734 else 1735 { 1736 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1737 } 1738 1739 foreach (var field in settings.GetFields()) 1740 { 1741 @Render(field) 1742 } 1743 1744 @:</form> 1745 } 1746 } 1747 @using System.Reflection 1748 @using Dynamicweb.Rapido.Blocks.Components.General 1749 @using Dynamicweb.Rapido.Blocks.Components 1750 1751 1752 @* Component *@ 1753 1754 @helper RenderText(Text settings) 1755 { 1756 @settings.Content 1757 } 1758 @using System.Reflection 1759 @using Dynamicweb.Rapido.Blocks.Components.General 1760 @using Dynamicweb.Rapido.Blocks.Components 1761 1762 1763 @* Component *@ 1764 1765 @helper RenderContentModule(ContentModule settings) { 1766 if (!string.IsNullOrEmpty(settings.Content)) 1767 { 1768 @settings.Content 1769 } 1770 } 1771 @using System.Reflection 1772 @using Dynamicweb.Rapido.Blocks.Components.General 1773 @using Dynamicweb.Rapido.Blocks.Components 1774 1775 1776 @* Component *@ 1777 1778 @helper RenderModal(Modal settings) { 1779 if (settings != null) 1780 { 1781 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1782 1783 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1784 1785 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1786 1787 <div class="modal-container"> 1788 @if (!settings.DisableDarkOverlay) 1789 { 1790 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1791 } 1792 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1793 @if (settings.Heading != null) 1794 { 1795 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1796 { 1797 <div class="modal__header"> 1798 @Render(settings.Heading) 1799 </div> 1800 } 1801 } 1802 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1803 @if (!string.IsNullOrEmpty(settings.BodyText)) 1804 { 1805 @settings.BodyText 1806 } 1807 @if (settings.BodyTemplate != null) 1808 { 1809 @settings.BodyTemplate 1810 } 1811 @{ 1812 var actions = settings.GetActions(); 1813 } 1814 </div> 1815 @if (actions.Length > 0) 1816 { 1817 <div class="modal__footer"> 1818 @foreach (var action in actions) 1819 { 1820 if (Pageview.Device.ToString() != "Mobile") { 1821 action.CssClass += " u-no-margin"; 1822 } else { 1823 action.CssClass += " u-full-width u-margin-bottom"; 1824 } 1825 1826 @Render(action) 1827 } 1828 </div> 1829 } 1830 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1831 </div> 1832 </div> 1833 } 1834 } 1835 @using Dynamicweb.Rapido.Blocks.Components.General 1836 1837 @* Component *@ 1838 1839 @helper RenderMediaListItem(MediaListItem settings) 1840 { 1841 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1842 @if (!string.IsNullOrEmpty(settings.Label)) 1843 { 1844 if (!string.IsNullOrEmpty(settings.Link)) 1845 { 1846 @Render(new Link 1847 { 1848 Href = settings.Link, 1849 CssClass = "media-list-item__sticker dw-mod", 1850 ButtonLayout = ButtonLayout.None, 1851 Title = settings.Label, 1852 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1853 }) 1854 } 1855 else if (!string.IsNullOrEmpty(settings.OnClick)) 1856 { 1857 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1858 <span class="u-uppercase">@settings.Label</span> 1859 </span> 1860 } 1861 else 1862 { 1863 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1864 <span class="u-uppercase">@settings.Label</span> 1865 </span> 1866 } 1867 } 1868 <div class="media-list-item__wrap"> 1869 <div class="media-list-item__info dw-mod"> 1870 <div class="media-list-item__header dw-mod"> 1871 @if (!string.IsNullOrEmpty(settings.Title)) 1872 { 1873 if (!string.IsNullOrEmpty(settings.Link)) 1874 { 1875 @Render(new Link 1876 { 1877 Href = settings.Link, 1878 CssClass = "media-list-item__name dw-mod", 1879 ButtonLayout = ButtonLayout.None, 1880 Title = settings.Title, 1881 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1882 }) 1883 } 1884 else if (!string.IsNullOrEmpty(settings.OnClick)) 1885 { 1886 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1887 } 1888 else 1889 { 1890 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1891 } 1892 } 1893 1894 @if (!string.IsNullOrEmpty(settings.Status)) 1895 { 1896 <div class="media-list-item__state dw-mod">@settings.Status</div> 1897 } 1898 </div> 1899 @{ 1900 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1901 } 1902 1903 @Render(settings.InfoTable) 1904 </div> 1905 <div class="media-list-item__actions dw-mod"> 1906 <div class="media-list-item__actions-list dw-mod"> 1907 @{ 1908 var actions = settings.GetActions(); 1909 1910 foreach (ButtonBase action in actions) 1911 { 1912 action.ButtonLayout = ButtonLayout.None; 1913 action.CssClass += " media-list-item__action link"; 1914 1915 @Render(action) 1916 } 1917 } 1918 </div> 1919 1920 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1921 { 1922 settings.SelectButton.CssClass += " u-no-margin"; 1923 1924 <div class="media-list-item__action-button"> 1925 @Render(settings.SelectButton) 1926 </div> 1927 } 1928 </div> 1929 </div> 1930 </div> 1931 } 1932 @using Dynamicweb.Rapido.Blocks.Components.General 1933 @using Dynamicweb.Rapido.Blocks.Components 1934 1935 @helper RenderTable(Table settings) 1936 { 1937 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1938 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1939 1940 var enumToClasses = new Dictionary<TableDesign, string> 1941 { 1942 { TableDesign.Clean, "table--clean" }, 1943 { TableDesign.Bordered, "table--bordered" }, 1944 { TableDesign.Striped, "table--striped" }, 1945 { TableDesign.Hover, "table--hover" }, 1946 { TableDesign.Compact, "table--compact" }, 1947 { TableDesign.Condensed, "table--condensed" }, 1948 { TableDesign.NoTopBorder, "table--no-top-border" } 1949 }; 1950 string tableDesignClass = ""; 1951 if (settings.Design != TableDesign.None) 1952 { 1953 tableDesignClass = enumToClasses[settings.Design]; 1954 } 1955 1956 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1957 1958 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1959 1960 <table @ComponentMethods.AddAttributes(resultAttributes)> 1961 @if (settings.Header != null) 1962 { 1963 <thead> 1964 @Render(settings.Header) 1965 </thead> 1966 } 1967 <tbody> 1968 @foreach (var row in settings.Rows) 1969 { 1970 @Render(row) 1971 } 1972 </tbody> 1973 @if (settings.Footer != null) 1974 { 1975 <tfoot> 1976 @Render(settings.Footer) 1977 </tfoot> 1978 } 1979 </table> 1980 } 1981 @using Dynamicweb.Rapido.Blocks.Components.General 1982 @using Dynamicweb.Rapido.Blocks.Components 1983 1984 @helper RenderTableRow(TableRow settings) 1985 { 1986 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1988 1989 var enumToClasses = new Dictionary<TableRowDesign, string> 1990 { 1991 { TableRowDesign.NoBorder, "table__row--no-border" }, 1992 { TableRowDesign.Border, "table__row--border" }, 1993 { TableRowDesign.TopBorder, "table__row--top-line" }, 1994 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1995 { TableRowDesign.Solid, "table__row--solid" } 1996 }; 1997 1998 string tableRowDesignClass = ""; 1999 if (settings.Design != TableRowDesign.None) 2000 { 2001 tableRowDesignClass = enumToClasses[settings.Design]; 2002 } 2003 2004 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2005 2006 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2007 2008 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2009 @foreach (var cell in settings.Cells) 2010 { 2011 if (settings.IsHeaderRow) 2012 { 2013 cell.IsHeader = true; 2014 } 2015 @Render(cell) 2016 } 2017 </tr> 2018 } 2019 @using Dynamicweb.Rapido.Blocks.Components.General 2020 @using Dynamicweb.Rapido.Blocks.Components 2021 @using Dynamicweb.Core 2022 2023 @helper RenderTableCell(TableCell settings) 2024 { 2025 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2026 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2027 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2028 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2029 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2030 2031 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2032 2033 string tagName = settings.IsHeader ? "th" : "td"; 2034 2035 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2036 @settings.Content 2037 @("</" + tagName + ">"); 2038 } 2039 @using System.Linq 2040 @using Dynamicweb.Rapido.Blocks.Components.General 2041 2042 @* Component *@ 2043 2044 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2045 { 2046 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2047 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2048 2049 if (settings.NumberOfPages > 1) 2050 { 2051 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2052 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2053 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2054 2055 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2056 @if (settings.ShowPagingInfo) 2057 { 2058 <div class="pager__info dw-mod"> 2059 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2060 </div> 2061 } 2062 <ul class="pager__list dw-mod"> 2063 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2064 { 2065 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2066 } 2067 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2068 { 2069 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2070 } 2071 @if (settings.GetPages().Any()) 2072 { 2073 foreach (var page in settings.GetPages()) 2074 { 2075 @Render(page) 2076 } 2077 } 2078 else 2079 { 2080 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2081 { 2082 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2083 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2084 } 2085 } 2086 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2087 { 2088 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2089 } 2090 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2091 { 2092 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2093 } 2094 </ul> 2095 </div> 2096 } 2097 } 2098 2099 @helper RenderPaginationItem(PaginationItem settings) 2100 { 2101 if (settings.Icon == null) 2102 { 2103 settings.Icon = new Icon(); 2104 } 2105 2106 settings.Icon.Label = settings.Label; 2107 <li class="pager__btn dw-mod"> 2108 @if (settings.IsActive) 2109 { 2110 <span class="pager__num pager__num--current dw-mod"> 2111 @Render(settings.Icon) 2112 </span> 2113 } 2114 else 2115 { 2116 <a href="@settings.Link" class="pager__num dw-mod"> 2117 @Render(settings.Icon) 2118 </a> 2119 } 2120 </li> 2121 } 2122 2123 2124 @using Dynamicweb.Rapido.Blocks.Components.General 2125 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2126 2127 2128 2129 2130 2131 @functions { 2132 public string GenerateRgba(string color, string opacity) 2133 { 2134 color = color.Replace("#", ""); 2135 if (color.Length == 6) { 2136 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 2137 } else { 2138 return Convert.ToInt16(color).ToString(); 2139 } 2140 } 2141 } 2142 2143 @{ 2144 string link = !string.IsNullOrEmpty(Model.Item.GetString("Link")) ? Model.Item.GetString("Link") : ""; 2145 string linkTarget = link.Contains("http") ? "_blank" : "_self"; 2146 } 2147 2148 @if (!string.IsNullOrEmpty(link)) { 2149 <a href="@link" target="@linkTarget" class="u-overlay">&nbsp;</a> 2150 @RenderTheContent() 2151 } else { 2152 @RenderTheContent() 2153 } 2154 2155 @helper RenderTheContent(){ 2156 var colorService = new ColorSwatchService(); 2157 2158 string innerPadding = Model.Item.GetList("Padding") != null ? " padding-size-" + Model.Item.GetList("Padding").SelectedValue.ToLower() : ""; 2159 innerPadding += Model.Item.GetList("PaddingPosition") != null ? " padding-position-" + Model.Item.GetList("PaddingPosition").SelectedValue.ToLower() : ""; 2160 string outerMargin = Model.Item.GetList("Margin") != null ? " margin-" + Model.Item.GetList("Margin").SelectedValue.ToLower() : ""; 2161 string outerMarginPosition = Model.Item.GetList("MarginPosition") != null ? " margin-position-" + Model.Item.GetList("MarginPosition").SelectedValue.ToLower() : ""; 2162 2163 string cardBackgroundColor = Model.Item.GetString("CardBackgroundColor") != null ? Model.Item.GetString("CardBackgroundColor") : ""; 2164 cardBackgroundColor = !cardBackgroundColor.Contains("#") ? colorService.GetHexColor(Pageview.AreaID, cardBackgroundColor) : cardBackgroundColor; 2165 string styles = "background-color: " + cardBackgroundColor + ";"; 2166 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) { 2167 int cropMode = !string.IsNullOrEmpty(Convert.ToString(Model.Item.GetList("ImageCrop"))) ? Convert.ToInt32(Model.Item.GetList("ImageCrop").SelectedValue) : 0; 2168 2169 Image image = new Image 2170 { 2171 Path = Model.Item.GetFile("Image") != null ? Model.Item.GetFile("Image").Path : "", 2172 CssClass = "background-image__cover", 2173 ImageDefault = new ImageSettings 2174 { 2175 Crop = cropMode, 2176 Height = 845, 2177 Width = 1920 2178 }, 2179 ImageMedium = new ImageSettings 2180 { 2181 Crop = cropMode, 2182 Height = 450, 2183 Width = 1024 2184 }, 2185 ImageSmall = new ImageSettings 2186 { 2187 Crop = cropMode, 2188 Height = 544, 2189 Width = 640 2190 } 2191 }; 2192 2193 image.FilterPrimary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2194 image.FilterSecondary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2195 2196 if (!string.IsNullOrEmpty(Model.Item.GetString("ColorForTheFilter"))) { 2197 image.FilterColor = Model.Item.GetString("ColorForTheFilter").StartsWith("#") ? GenerateRgba(Model.Item.GetString("ColorForTheFilter"), "0.3") : ""; 2198 } 2199 2200 <div class="background-image dw-mod"> 2201 <div class="background-image__wrapper dw-mod"> 2202 @Render(image) 2203 </div> 2204 </div> 2205 } 2206 2207 <div class="content-row__item__body @innerPadding @outerMargin @outerMarginPosition card-paragraph dw-mod" style="@styles"> 2208 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Text"))) { 2209 if (!Model.Item.GetBoolean("HideTitle")) { 2210 @Render(new Heading { Title = Model.Item.GetString("Title"), CssClass = "u-no-margin", Level = 2 }) 2211 } 2212 @Render(new Text { Content = Model.Item.GetString("Text") }) 2213 } 2214 2215 @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"))) { 2216 <div> 2217 @ParagraphButton(Model.Item.GetItem("ButtonOne")) 2218 @ParagraphButton(Model.Item.GetItem("ButtonTwo")) 2219 @ParagraphButton(Model.Item.GetItem("ButtonThree")) 2220 </div> 2221 } 2222 </div> 2223 } 2224 2225 2226 @helper ParagraphButton(ItemViewModel item) { 2227 if (item != null) { 2228 if (!string.IsNullOrEmpty(item.GetString("Title"))) { 2229 Button button = new Button { 2230 Title = item.GetString("Title"), 2231 Href = item.GetString("Link"), 2232 CssClass = "u-no-margin", 2233 ButtonLayout = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("Layout").SelectedValue[0]) + item.GetList("Layout").SelectedValue.Substring(1)) 2234 }; 2235 2236 if (!string.IsNullOrEmpty(item.GetString("Icon"))) { 2237 button.Icon = new Icon { 2238 CssClass = item.GetString("Icon") 2239 }; 2240 } 2241 2242 @Render(button) 2243 } 2244 } 2245 } 2246 2247 2248 2249 2250
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_3d17c237f02b45fb9168be3d2dae3286.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2215
   at CompiledRazorTemplates.Dynamic.RazorEngine_3d17c237f02b45fb9168be3d2dae3286.Execute() in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2152
   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 if (settings.ExtraAttributes == null) 898 { 899 settings.ExtraAttributes = new Dictionary<string, string>(); 900 } 901 settings.ExtraAttributes.Add("autocomplete","off"); 902 var textField = new TextField { 903 Name = settings.Name, 904 Id = settings.Id, 905 Label = settings.Label, 906 HelpText = settings.HelpText, 907 Value = settings.Value, 908 Disabled = settings.Disabled, 909 Required = settings.Required, 910 ErrorMessage = settings.ErrorMessage, 911 CssClass = settings.CssClass, 912 WrapperCssClass = settings.WrapperCssClass, 913 OnChange = settings.OnChange, 914 OnClick = settings.OnClick, 915 Link = settings.Link, 916 ExtraAttributes = settings.ExtraAttributes, 917 // 918 Placeholder = settings.Placeholder 919 }; 920 921 @Render(textField) 922 923 List<string> jsAttributes = new List<string>(); 924 925 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 926 927 if (!string.IsNullOrEmpty(settings.DateFormat)) 928 { 929 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 930 } 931 if (!string.IsNullOrEmpty(settings.MinDate)) 932 { 933 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 934 } 935 if (!string.IsNullOrEmpty(settings.MaxDate)) 936 { 937 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 938 } 939 if (settings.IsInline) 940 { 941 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 942 } 943 if (settings.EnableTime) 944 { 945 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 946 } 947 if (settings.EnableWeekNumbers) 948 { 949 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 950 } 951 952 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 953 954 <script> 955 document.addEventListener( "DOMContentLoaded", function () { 956 flatpickr("#@textField.Id", { 957 onReady: function(selectedDates, dateStr, instance) { 958 instance.input.readOnly = false; 959 }, 960 onOpen: function(selectedDates, dateStr, instance) { 961 instance.input.readOnly = true; 962 }, 963 onClose: function(selectedDates, dateStr, instance) { 964 instance.input.readOnly = false; 965 //instance.input.blur(); 966 }, 967 @string.Join(",", jsAttributes) 968 } ) 969 } ); 970 </script> 971 } 972 @using System.Reflection 973 @using Dynamicweb.Rapido.Blocks.Components.General 974 @using Dynamicweb.Rapido.Blocks.Components 975 976 @* Component *@ 977 978 @helper RenderTextField(TextField settings) 979 { 980 var attributes = new Dictionary<string, string>(); 981 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 982 { 983 settings.Id = Guid.NewGuid().ToString("N"); 984 } 985 986 /*base settings*/ 987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 988 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 989 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 990 if (settings.Disabled) { attributes.Add("disabled", "true"); } 991 if (settings.Required) { attributes.Add("required", "true"); } 992 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 993 /*end*/ 994 995 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 996 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 997 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 998 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 999 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1000 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1001 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1002 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1003 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1004 1005 settings.CssClass = "u-full-width " + settings.CssClass; 1006 1007 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1008 1009 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1010 1011 string noMargin = "u-no-margin"; 1012 if (!settings.ReadOnly) { 1013 noMargin = ""; 1014 } 1015 1016 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1017 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1018 { 1019 <div class="u-full-width"> 1020 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1021 @if (settings.Link != null) { 1022 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1023 1024 <div class="u-pull--right"> 1025 @Render(settings.Link) 1026 </div> 1027 } 1028 </div> 1029 1030 } 1031 1032 @if (!string.IsNullOrEmpty(settings.HelpText)) 1033 { 1034 <small class="form__help-text">@settings.HelpText</small> 1035 } 1036 1037 @if (settings.ActionButton != null) 1038 { 1039 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1040 <div class="form__field-combi u-no-margin dw-mod"> 1041 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1042 @Render(settings.ActionButton) 1043 </div> 1044 } 1045 else 1046 { 1047 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1048 } 1049 1050 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1051 </div> 1052 } 1053 @using System.Reflection 1054 @using Dynamicweb.Rapido.Blocks.Components.General 1055 @using Dynamicweb.Rapido.Blocks.Components 1056 1057 @* Component *@ 1058 1059 @helper RenderNumberField(NumberField settings) 1060 { 1061 var attributes = new Dictionary<string, string>(); 1062 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1063 { 1064 settings.Id = Guid.NewGuid().ToString("N"); 1065 } 1066 1067 /*base settings*/ 1068 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1069 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1070 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1071 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1072 if (settings.Required) { attributes.Add("required", "true"); } 1073 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1074 /*end*/ 1075 1076 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1077 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1078 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1079 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1080 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1081 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1082 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1083 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1084 attributes.Add("type", "number"); 1085 1086 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1087 1088 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1089 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1090 { 1091 <div class="u-full-width"> 1092 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1093 @if (settings.Link != null) { 1094 <div class="u-pull--right"> 1095 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1096 @Render(settings.Link) 1097 </div> 1098 } 1099 </div> 1100 1101 } 1102 1103 @if (!string.IsNullOrEmpty(settings.HelpText)) 1104 { 1105 <small class="form__help-text">@settings.HelpText</small> 1106 } 1107 1108 @if (settings.ActionButton != null) 1109 { 1110 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1111 <div class="form__field-combi u-no-margin dw-mod"> 1112 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1113 @Render(settings.ActionButton) 1114 </div> 1115 } 1116 else 1117 { 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 </div> 1121 } 1122 1123 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1124 </div> 1125 } 1126 @using System.Reflection 1127 @using Dynamicweb.Rapido.Blocks.Components.General 1128 @using Dynamicweb.Rapido.Blocks.Components 1129 1130 1131 @* Component *@ 1132 1133 @helper RenderTextareaField(TextareaField settings) 1134 { 1135 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1136 string id = settings.Id; 1137 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1138 { 1139 id = Guid.NewGuid().ToString("N"); 1140 } 1141 1142 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1143 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1144 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1145 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1146 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1147 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1148 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1149 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1150 if (settings.Required) { attributes.Add("required", "true"); } 1151 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1152 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1153 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1154 attributes.Add("name", settings.Name); 1155 1156 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1157 1158 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1159 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1160 { 1161 <div class="u-full-width"> 1162 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1163 @if (settings.Link != null) { 1164 <div class="u-pull--right"> 1165 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1166 @Render(settings.Link) 1167 </div> 1168 } 1169 </div> 1170 } 1171 1172 @if (!string.IsNullOrEmpty(settings.HelpText)) 1173 { 1174 <small class="form__help-text">@settings.HelpText</small> 1175 } 1176 1177 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1178 1179 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1180 </div> 1181 } 1182 @using System.Reflection 1183 @using Dynamicweb.Rapido.Blocks.Components.General 1184 @using Dynamicweb.Rapido.Blocks.Components 1185 1186 1187 @* Component *@ 1188 1189 @helper RenderHiddenField(HiddenField settings) { 1190 var attributes = new Dictionary<string, string>(); 1191 attributes.Add("type", "hidden"); 1192 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1193 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1195 1196 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1197 } 1198 @using System.Reflection 1199 @using Dynamicweb.Rapido.Blocks.Components.General 1200 @using Dynamicweb.Rapido.Blocks.Components 1201 1202 @* Component *@ 1203 1204 @helper RenderCheckboxField(CheckboxField settings) 1205 { 1206 var attributes = new Dictionary<string, string>(); 1207 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1208 { 1209 settings.Id = Guid.NewGuid().ToString("N"); 1210 } 1211 1212 /*base settings*/ 1213 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1214 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1215 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1216 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1217 if (settings.Required) { attributes.Add("required", "true"); } 1218 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1219 /*end*/ 1220 1221 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1222 1223 attributes.Add("type", "checkbox"); 1224 if (settings.Checked) { attributes.Add("checked", "true"); } 1225 settings.CssClass = "form__control " + settings.CssClass; 1226 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1227 1228 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1229 1230 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1231 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1232 @if (!string.IsNullOrEmpty(settings.Label)) 1233 { 1234 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1235 } 1236 1237 @if (settings.Link != null) { 1238 <span> 1239 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1240 @Render(settings.Link) 1241 </span> 1242 } 1243 1244 @if (!string.IsNullOrEmpty(settings.HelpText)) 1245 { 1246 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1247 } 1248 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1249 </div> 1250 } 1251 @using System.Reflection 1252 @using Dynamicweb.Rapido.Blocks.Components.General 1253 @using Dynamicweb.Rapido.Blocks.Components 1254 1255 1256 @* Component *@ 1257 1258 @helper RenderCheckboxListField(CheckboxListField settings) 1259 { 1260 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1261 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1262 { 1263 <div class="u-full-width"> 1264 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1265 @if (settings.Link != null) { 1266 <div class="u-pull--right"> 1267 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1268 @Render(settings.Link) 1269 </div> 1270 } 1271 </div> 1272 1273 } 1274 1275 <div class="u-pull--left"> 1276 @if (!string.IsNullOrEmpty(settings.HelpText)) 1277 { 1278 <small class="form__help-text">@settings.HelpText</small> 1279 } 1280 1281 @foreach (var item in settings.Options) 1282 { 1283 if (settings.Required) 1284 { 1285 item.Required = true; 1286 } 1287 if (settings.Disabled) 1288 { 1289 item.Disabled = true; 1290 } 1291 if (!string.IsNullOrEmpty(settings.Name)) 1292 { 1293 item.Name = settings.Name; 1294 } 1295 if (!string.IsNullOrEmpty(settings.CssClass)) 1296 { 1297 item.CssClass += settings.CssClass; 1298 } 1299 1300 /* value is not supported */ 1301 1302 if (!string.IsNullOrEmpty(settings.OnClick)) 1303 { 1304 item.OnClick += settings.OnClick; 1305 } 1306 if (!string.IsNullOrEmpty(settings.OnChange)) 1307 { 1308 item.OnChange += settings.OnChange; 1309 } 1310 @Render(item) 1311 } 1312 1313 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1314 </div> 1315 1316 </div> 1317 } 1318 @using Dynamicweb.Rapido.Blocks.Components.General 1319 1320 @* Component *@ 1321 1322 @helper RenderSearch(Search settings) 1323 { 1324 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1325 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1326 1327 if (string.IsNullOrEmpty(settings.Id)) 1328 { 1329 settings.Id = Guid.NewGuid().ToString("N"); 1330 } 1331 1332 var resultAttributes = new Dictionary<string, string>(); 1333 1334 if (settings.PageSize != 0) 1335 { 1336 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1337 } 1338 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1339 { 1340 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1341 if (!string.IsNullOrEmpty(groupValue)) 1342 { 1343 resultAttributes.Add("data-selected-group", groupValue); 1344 } 1345 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1346 { 1347 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1348 } 1349 } 1350 resultAttributes.Add("data-force-init", "true"); 1351 if (settings.GoToFirstSearchResultOnEnter) 1352 { 1353 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1354 } 1355 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1356 { 1357 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1358 } 1359 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1360 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1361 1362 if (settings.SecondSearchData != null) 1363 { 1364 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1365 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1366 } 1367 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1368 { 1369 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1370 } 1371 1372 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1373 1374 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1375 1376 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1377 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1378 { 1379 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1380 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1381 } 1382 1383 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1384 1385 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1386 @if (settings.SecondSearchData != null) 1387 { 1388 <div class="search__column search__column--products dw-mod"> 1389 <div class="search__column-header dw-mod">@Translate("Products")</div> 1390 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1391 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1392 { 1393 @Render(new Link { 1394 Title = Translate("View all"), 1395 CssClass = "js-view-all-button u-margin", 1396 Href = settings.SearchData.ResultsPageUrl 1397 }); 1398 } 1399 </div> 1400 <div class="search__column search__column--pages dw-mod"> 1401 <div class="search__column-header">@Translate("Pages")</div> 1402 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1403 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1404 { 1405 @Render(new Link 1406 { 1407 Title = Translate("View all"), 1408 CssClass = "js-view-all-button u-margin", 1409 Href = settings.SecondSearchData.ResultsPageUrl 1410 }); 1411 } 1412 </div> 1413 } 1414 else 1415 { 1416 <div class="search__column search__column--only dw-mod"> 1417 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1418 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1419 { 1420 @Render(new Link { 1421 Title = Translate("View all"), 1422 CssClass = "js-view-all-button u-margin", 1423 Href = settings.SearchData.ResultsPageUrl 1424 }); 1425 } 1426 </div> 1427 } 1428 </div> 1429 1430 @if (settings.SearchButton != null) 1431 { 1432 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1433 if (settings.RenderDefaultSearchIcon) 1434 { 1435 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1436 } 1437 @Render(settings.SearchButton); 1438 } 1439 </div> 1440 } 1441 @using System.Reflection 1442 @using Dynamicweb.Rapido.Blocks.Components.General 1443 @using Dynamicweb.Rapido.Blocks.Components 1444 1445 1446 @* Component *@ 1447 1448 @helper RenderSelectField(SelectField settings) 1449 { 1450 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1451 { 1452 settings.Id = Guid.NewGuid().ToString("N"); 1453 } 1454 1455 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1456 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1457 { 1458 <div class="u-full-width"> 1459 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1460 @if (settings.Link != null) { 1461 <div class="u-pull--right"> 1462 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1463 @Render(settings.Link) 1464 </div> 1465 } 1466 </div> 1467 } 1468 1469 @if (!string.IsNullOrEmpty(settings.HelpText)) 1470 { 1471 <small class="form__help-text">@settings.HelpText</small> 1472 } 1473 1474 @if (settings.ActionButton != null) 1475 { 1476 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1477 <div class="form__field-combi u-no-margin dw-mod"> 1478 @RenderSelectBase(settings) 1479 @Render(settings.ActionButton) 1480 </div> 1481 } 1482 else 1483 { 1484 @RenderSelectBase(settings) 1485 } 1486 1487 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1488 </div> 1489 } 1490 1491 @helper RenderSelectBase(SelectField settings) 1492 { 1493 var attributes = new Dictionary<string, string>(); 1494 1495 /*base settings*/ 1496 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1497 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1498 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1499 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1500 if (settings.Required) { attributes.Add("required", "true"); } 1501 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1502 /*end*/ 1503 1504 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1505 1506 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1507 @if (settings.Default != null) 1508 { 1509 @Render(settings.Default) 1510 } 1511 1512 @foreach (var item in settings.Options) 1513 { 1514 if (settings.Value != null) { 1515 item.Checked = item.Value == settings.Value; 1516 } 1517 @Render(item) 1518 } 1519 </select> 1520 } 1521 @using System.Reflection 1522 @using Dynamicweb.Rapido.Blocks.Components.General 1523 @using Dynamicweb.Rapido.Blocks.Components 1524 1525 @* Component *@ 1526 1527 @helper RenderRadioButtonField(RadioButtonField settings) 1528 { 1529 var attributes = new Dictionary<string, string>(); 1530 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1531 { 1532 settings.Id = Guid.NewGuid().ToString("N"); 1533 } 1534 1535 /*base settings*/ 1536 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1537 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1538 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1539 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1540 if (settings.Required) { attributes.Add("required", "true"); } 1541 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1542 /*end*/ 1543 1544 attributes.Add("type", "radio"); 1545 if (settings.Checked) { attributes.Add("checked", "true"); } 1546 settings.CssClass = "form__control " + settings.CssClass; 1547 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1548 1549 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1550 1551 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1552 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1553 @if (!string.IsNullOrEmpty(settings.Label)) 1554 { 1555 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1556 } 1557 @if (!string.IsNullOrEmpty(settings.HelpText)) 1558 { 1559 <small class="form__help-text">@settings.HelpText</small> 1560 } 1561 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1562 </div> 1563 } 1564 @using System.Reflection 1565 @using Dynamicweb.Rapido.Blocks.Components.General 1566 @using Dynamicweb.Rapido.Blocks.Components 1567 1568 1569 @* Component *@ 1570 1571 @helper RenderRadioButtonListField(RadioButtonListField settings) 1572 { 1573 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1574 1575 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1576 @if (!string.IsNullOrEmpty(settings.Label)) 1577 { 1578 <label>@settings.Label</label> 1579 } 1580 @if (!string.IsNullOrEmpty(settings.HelpText)) 1581 { 1582 <small class="form__help-text">@settings.HelpText</small> 1583 } 1584 1585 @foreach (var item in settings.Options) 1586 { 1587 if (settings.Required) 1588 { 1589 item.Required = true; 1590 } 1591 if (settings.Disabled) 1592 { 1593 item.Disabled = true; 1594 } 1595 if (!string.IsNullOrEmpty(settings.Name)) 1596 { 1597 item.Name = settings.Name; 1598 } 1599 if (settings.Value != null && settings.Value == item.Value) 1600 { 1601 item.Checked = true; 1602 } 1603 if (!string.IsNullOrEmpty(settings.OnClick)) 1604 { 1605 item.OnClick += settings.OnClick; 1606 } 1607 if (!string.IsNullOrEmpty(settings.OnChange)) 1608 { 1609 item.OnChange += settings.OnChange; 1610 } 1611 if (!string.IsNullOrEmpty(settings.CssClass)) 1612 { 1613 item.CssClass += settings.CssClass; 1614 } 1615 @Render(item) 1616 } 1617 1618 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1619 </div> 1620 } 1621 @using System.Reflection 1622 @using Dynamicweb.Rapido.Blocks.Components.General 1623 @using Dynamicweb.Rapido.Blocks.Components 1624 1625 1626 @* Component *@ 1627 1628 @helper RenderNotificationMessage(NotificationMessage settings) 1629 { 1630 if (!string.IsNullOrEmpty(settings.Message)) 1631 { 1632 var attributes = new Dictionary<string, string>(); 1633 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1634 1635 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1636 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1637 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1638 1639 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1640 @if (settings.Icon != null) { 1641 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1642 @Render(settings.Icon) 1643 } else { 1644 @settings.Message 1645 } 1646 </div> 1647 } 1648 } 1649 @using Dynamicweb.Rapido.Blocks.Components.General 1650 1651 1652 @* Component *@ 1653 1654 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1655 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1656 1657 <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> 1658 @if (settings.SubBlocks != null) { 1659 @RenderBlockList(settings.SubBlocks) 1660 } 1661 </div> 1662 } 1663 @using System.Reflection 1664 @using Dynamicweb.Rapido.Blocks.Components.General 1665 @using Dynamicweb.Rapido.Blocks.Components 1666 @using System.Text.RegularExpressions 1667 1668 1669 @* Component *@ 1670 1671 @helper RenderSticker(Sticker settings) { 1672 if (!String.IsNullOrEmpty(settings.Title)) { 1673 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1674 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1675 1676 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1677 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1678 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1679 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1680 optionalAttributes.Add("style", styleTag); 1681 } 1682 1683 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1684 } 1685 } 1686 1687 @using System.Reflection 1688 @using Dynamicweb.Rapido.Blocks.Components.General 1689 @using Dynamicweb.Rapido.Blocks.Components 1690 1691 1692 @* Component *@ 1693 1694 @helper RenderStickersCollection(StickersCollection settings) 1695 { 1696 if (settings.Stickers.Count > 0) 1697 { 1698 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1699 1700 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1701 @foreach (Sticker sticker in settings.Stickers) 1702 { 1703 @Render(sticker) 1704 } 1705 </div> 1706 } 1707 } 1708 1709 @using Dynamicweb.Rapido.Blocks.Components.General 1710 1711 1712 @* Component *@ 1713 1714 @helper RenderForm(Form settings) { 1715 if (settings != null) 1716 { 1717 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1718 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1719 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1720 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1721 var enctypes = new Dictionary<string, string> 1722 { 1723 { "multipart", "multipart/form-data" }, 1724 { "text", "text/plain" }, 1725 { "application", "application/x-www-form-urlencoded" } 1726 }; 1727 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1728 optionalAttributes.Add("method", settings.Method.ToString()); 1729 1730 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1731 { 1732 @settings.FormStartMarkup 1733 } 1734 else 1735 { 1736 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1737 } 1738 1739 foreach (var field in settings.GetFields()) 1740 { 1741 @Render(field) 1742 } 1743 1744 @:</form> 1745 } 1746 } 1747 @using System.Reflection 1748 @using Dynamicweb.Rapido.Blocks.Components.General 1749 @using Dynamicweb.Rapido.Blocks.Components 1750 1751 1752 @* Component *@ 1753 1754 @helper RenderText(Text settings) 1755 { 1756 @settings.Content 1757 } 1758 @using System.Reflection 1759 @using Dynamicweb.Rapido.Blocks.Components.General 1760 @using Dynamicweb.Rapido.Blocks.Components 1761 1762 1763 @* Component *@ 1764 1765 @helper RenderContentModule(ContentModule settings) { 1766 if (!string.IsNullOrEmpty(settings.Content)) 1767 { 1768 @settings.Content 1769 } 1770 } 1771 @using System.Reflection 1772 @using Dynamicweb.Rapido.Blocks.Components.General 1773 @using Dynamicweb.Rapido.Blocks.Components 1774 1775 1776 @* Component *@ 1777 1778 @helper RenderModal(Modal settings) { 1779 if (settings != null) 1780 { 1781 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1782 1783 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1784 1785 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1786 1787 <div class="modal-container"> 1788 @if (!settings.DisableDarkOverlay) 1789 { 1790 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1791 } 1792 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1793 @if (settings.Heading != null) 1794 { 1795 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1796 { 1797 <div class="modal__header"> 1798 @Render(settings.Heading) 1799 </div> 1800 } 1801 } 1802 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1803 @if (!string.IsNullOrEmpty(settings.BodyText)) 1804 { 1805 @settings.BodyText 1806 } 1807 @if (settings.BodyTemplate != null) 1808 { 1809 @settings.BodyTemplate 1810 } 1811 @{ 1812 var actions = settings.GetActions(); 1813 } 1814 </div> 1815 @if (actions.Length > 0) 1816 { 1817 <div class="modal__footer"> 1818 @foreach (var action in actions) 1819 { 1820 if (Pageview.Device.ToString() != "Mobile") { 1821 action.CssClass += " u-no-margin"; 1822 } else { 1823 action.CssClass += " u-full-width u-margin-bottom"; 1824 } 1825 1826 @Render(action) 1827 } 1828 </div> 1829 } 1830 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1831 </div> 1832 </div> 1833 } 1834 } 1835 @using Dynamicweb.Rapido.Blocks.Components.General 1836 1837 @* Component *@ 1838 1839 @helper RenderMediaListItem(MediaListItem settings) 1840 { 1841 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1842 @if (!string.IsNullOrEmpty(settings.Label)) 1843 { 1844 if (!string.IsNullOrEmpty(settings.Link)) 1845 { 1846 @Render(new Link 1847 { 1848 Href = settings.Link, 1849 CssClass = "media-list-item__sticker dw-mod", 1850 ButtonLayout = ButtonLayout.None, 1851 Title = settings.Label, 1852 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1853 }) 1854 } 1855 else if (!string.IsNullOrEmpty(settings.OnClick)) 1856 { 1857 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1858 <span class="u-uppercase">@settings.Label</span> 1859 </span> 1860 } 1861 else 1862 { 1863 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1864 <span class="u-uppercase">@settings.Label</span> 1865 </span> 1866 } 1867 } 1868 <div class="media-list-item__wrap"> 1869 <div class="media-list-item__info dw-mod"> 1870 <div class="media-list-item__header dw-mod"> 1871 @if (!string.IsNullOrEmpty(settings.Title)) 1872 { 1873 if (!string.IsNullOrEmpty(settings.Link)) 1874 { 1875 @Render(new Link 1876 { 1877 Href = settings.Link, 1878 CssClass = "media-list-item__name dw-mod", 1879 ButtonLayout = ButtonLayout.None, 1880 Title = settings.Title, 1881 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1882 }) 1883 } 1884 else if (!string.IsNullOrEmpty(settings.OnClick)) 1885 { 1886 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1887 } 1888 else 1889 { 1890 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1891 } 1892 } 1893 1894 @if (!string.IsNullOrEmpty(settings.Status)) 1895 { 1896 <div class="media-list-item__state dw-mod">@settings.Status</div> 1897 } 1898 </div> 1899 @{ 1900 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1901 } 1902 1903 @Render(settings.InfoTable) 1904 </div> 1905 <div class="media-list-item__actions dw-mod"> 1906 <div class="media-list-item__actions-list dw-mod"> 1907 @{ 1908 var actions = settings.GetActions(); 1909 1910 foreach (ButtonBase action in actions) 1911 { 1912 action.ButtonLayout = ButtonLayout.None; 1913 action.CssClass += " media-list-item__action link"; 1914 1915 @Render(action) 1916 } 1917 } 1918 </div> 1919 1920 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1921 { 1922 settings.SelectButton.CssClass += " u-no-margin"; 1923 1924 <div class="media-list-item__action-button"> 1925 @Render(settings.SelectButton) 1926 </div> 1927 } 1928 </div> 1929 </div> 1930 </div> 1931 } 1932 @using Dynamicweb.Rapido.Blocks.Components.General 1933 @using Dynamicweb.Rapido.Blocks.Components 1934 1935 @helper RenderTable(Table settings) 1936 { 1937 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1938 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1939 1940 var enumToClasses = new Dictionary<TableDesign, string> 1941 { 1942 { TableDesign.Clean, "table--clean" }, 1943 { TableDesign.Bordered, "table--bordered" }, 1944 { TableDesign.Striped, "table--striped" }, 1945 { TableDesign.Hover, "table--hover" }, 1946 { TableDesign.Compact, "table--compact" }, 1947 { TableDesign.Condensed, "table--condensed" }, 1948 { TableDesign.NoTopBorder, "table--no-top-border" } 1949 }; 1950 string tableDesignClass = ""; 1951 if (settings.Design != TableDesign.None) 1952 { 1953 tableDesignClass = enumToClasses[settings.Design]; 1954 } 1955 1956 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1957 1958 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1959 1960 <table @ComponentMethods.AddAttributes(resultAttributes)> 1961 @if (settings.Header != null) 1962 { 1963 <thead> 1964 @Render(settings.Header) 1965 </thead> 1966 } 1967 <tbody> 1968 @foreach (var row in settings.Rows) 1969 { 1970 @Render(row) 1971 } 1972 </tbody> 1973 @if (settings.Footer != null) 1974 { 1975 <tfoot> 1976 @Render(settings.Footer) 1977 </tfoot> 1978 } 1979 </table> 1980 } 1981 @using Dynamicweb.Rapido.Blocks.Components.General 1982 @using Dynamicweb.Rapido.Blocks.Components 1983 1984 @helper RenderTableRow(TableRow settings) 1985 { 1986 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1988 1989 var enumToClasses = new Dictionary<TableRowDesign, string> 1990 { 1991 { TableRowDesign.NoBorder, "table__row--no-border" }, 1992 { TableRowDesign.Border, "table__row--border" }, 1993 { TableRowDesign.TopBorder, "table__row--top-line" }, 1994 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1995 { TableRowDesign.Solid, "table__row--solid" } 1996 }; 1997 1998 string tableRowDesignClass = ""; 1999 if (settings.Design != TableRowDesign.None) 2000 { 2001 tableRowDesignClass = enumToClasses[settings.Design]; 2002 } 2003 2004 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2005 2006 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2007 2008 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2009 @foreach (var cell in settings.Cells) 2010 { 2011 if (settings.IsHeaderRow) 2012 { 2013 cell.IsHeader = true; 2014 } 2015 @Render(cell) 2016 } 2017 </tr> 2018 } 2019 @using Dynamicweb.Rapido.Blocks.Components.General 2020 @using Dynamicweb.Rapido.Blocks.Components 2021 @using Dynamicweb.Core 2022 2023 @helper RenderTableCell(TableCell settings) 2024 { 2025 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2026 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2027 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2028 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2029 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2030 2031 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2032 2033 string tagName = settings.IsHeader ? "th" : "td"; 2034 2035 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2036 @settings.Content 2037 @("</" + tagName + ">"); 2038 } 2039 @using System.Linq 2040 @using Dynamicweb.Rapido.Blocks.Components.General 2041 2042 @* Component *@ 2043 2044 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2045 { 2046 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2047 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2048 2049 if (settings.NumberOfPages > 1) 2050 { 2051 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2052 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2053 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2054 2055 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2056 @if (settings.ShowPagingInfo) 2057 { 2058 <div class="pager__info dw-mod"> 2059 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2060 </div> 2061 } 2062 <ul class="pager__list dw-mod"> 2063 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2064 { 2065 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2066 } 2067 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2068 { 2069 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2070 } 2071 @if (settings.GetPages().Any()) 2072 { 2073 foreach (var page in settings.GetPages()) 2074 { 2075 @Render(page) 2076 } 2077 } 2078 else 2079 { 2080 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2081 { 2082 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2083 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2084 } 2085 } 2086 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2087 { 2088 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2089 } 2090 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2091 { 2092 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2093 } 2094 </ul> 2095 </div> 2096 } 2097 } 2098 2099 @helper RenderPaginationItem(PaginationItem settings) 2100 { 2101 if (settings.Icon == null) 2102 { 2103 settings.Icon = new Icon(); 2104 } 2105 2106 settings.Icon.Label = settings.Label; 2107 <li class="pager__btn dw-mod"> 2108 @if (settings.IsActive) 2109 { 2110 <span class="pager__num pager__num--current dw-mod"> 2111 @Render(settings.Icon) 2112 </span> 2113 } 2114 else 2115 { 2116 <a href="@settings.Link" class="pager__num dw-mod"> 2117 @Render(settings.Icon) 2118 </a> 2119 } 2120 </li> 2121 } 2122 2123 2124 @using Dynamicweb.Rapido.Blocks.Components.General 2125 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2126 2127 2128 2129 2130 2131 @functions { 2132 public string GenerateRgba(string color, string opacity) 2133 { 2134 color = color.Replace("#", ""); 2135 if (color.Length == 6) { 2136 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 2137 } else { 2138 return Convert.ToInt16(color).ToString(); 2139 } 2140 } 2141 } 2142 2143 @{ 2144 string link = !string.IsNullOrEmpty(Model.Item.GetString("Link")) ? Model.Item.GetString("Link") : ""; 2145 string linkTarget = link.Contains("http") ? "_blank" : "_self"; 2146 } 2147 2148 @if (!string.IsNullOrEmpty(link)) { 2149 <a href="@link" target="@linkTarget" class="u-overlay">&nbsp;</a> 2150 @RenderTheContent() 2151 } else { 2152 @RenderTheContent() 2153 } 2154 2155 @helper RenderTheContent(){ 2156 var colorService = new ColorSwatchService(); 2157 2158 string innerPadding = Model.Item.GetList("Padding") != null ? " padding-size-" + Model.Item.GetList("Padding").SelectedValue.ToLower() : ""; 2159 innerPadding += Model.Item.GetList("PaddingPosition") != null ? " padding-position-" + Model.Item.GetList("PaddingPosition").SelectedValue.ToLower() : ""; 2160 string outerMargin = Model.Item.GetList("Margin") != null ? " margin-" + Model.Item.GetList("Margin").SelectedValue.ToLower() : ""; 2161 string outerMarginPosition = Model.Item.GetList("MarginPosition") != null ? " margin-position-" + Model.Item.GetList("MarginPosition").SelectedValue.ToLower() : ""; 2162 2163 string cardBackgroundColor = Model.Item.GetString("CardBackgroundColor") != null ? Model.Item.GetString("CardBackgroundColor") : ""; 2164 cardBackgroundColor = !cardBackgroundColor.Contains("#") ? colorService.GetHexColor(Pageview.AreaID, cardBackgroundColor) : cardBackgroundColor; 2165 string styles = "background-color: " + cardBackgroundColor + ";"; 2166 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) { 2167 int cropMode = !string.IsNullOrEmpty(Convert.ToString(Model.Item.GetList("ImageCrop"))) ? Convert.ToInt32(Model.Item.GetList("ImageCrop").SelectedValue) : 0; 2168 2169 Image image = new Image 2170 { 2171 Path = Model.Item.GetFile("Image") != null ? Model.Item.GetFile("Image").Path : "", 2172 CssClass = "background-image__cover", 2173 ImageDefault = new ImageSettings 2174 { 2175 Crop = cropMode, 2176 Height = 845, 2177 Width = 1920 2178 }, 2179 ImageMedium = new ImageSettings 2180 { 2181 Crop = cropMode, 2182 Height = 450, 2183 Width = 1024 2184 }, 2185 ImageSmall = new ImageSettings 2186 { 2187 Crop = cropMode, 2188 Height = 544, 2189 Width = 640 2190 } 2191 }; 2192 2193 image.FilterPrimary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2194 image.FilterSecondary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2195 2196 if (!string.IsNullOrEmpty(Model.Item.GetString("ColorForTheFilter"))) { 2197 image.FilterColor = Model.Item.GetString("ColorForTheFilter").StartsWith("#") ? GenerateRgba(Model.Item.GetString("ColorForTheFilter"), "0.3") : ""; 2198 } 2199 2200 <div class="background-image dw-mod"> 2201 <div class="background-image__wrapper dw-mod"> 2202 @Render(image) 2203 </div> 2204 </div> 2205 } 2206 2207 <div class="content-row__item__body @innerPadding @outerMargin @outerMarginPosition card-paragraph dw-mod" style="@styles"> 2208 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Text"))) { 2209 if (!Model.Item.GetBoolean("HideTitle")) { 2210 @Render(new Heading { Title = Model.Item.GetString("Title"), CssClass = "u-no-margin", Level = 2 }) 2211 } 2212 @Render(new Text { Content = Model.Item.GetString("Text") }) 2213 } 2214 2215 @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"))) { 2216 <div> 2217 @ParagraphButton(Model.Item.GetItem("ButtonOne")) 2218 @ParagraphButton(Model.Item.GetItem("ButtonTwo")) 2219 @ParagraphButton(Model.Item.GetItem("ButtonThree")) 2220 </div> 2221 } 2222 </div> 2223 } 2224 2225 2226 @helper ParagraphButton(ItemViewModel item) { 2227 if (item != null) { 2228 if (!string.IsNullOrEmpty(item.GetString("Title"))) { 2229 Button button = new Button { 2230 Title = item.GetString("Title"), 2231 Href = item.GetString("Link"), 2232 CssClass = "u-no-margin", 2233 ButtonLayout = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("Layout").SelectedValue[0]) + item.GetList("Layout").SelectedValue.Substring(1)) 2234 }; 2235 2236 if (!string.IsNullOrEmpty(item.GetString("Icon"))) { 2237 button.Icon = new Icon { 2238 CssClass = item.GetString("Icon") 2239 }; 2240 } 2241 2242 @Render(button) 2243 } 2244 } 2245 } 2246 2247 2248 2249 2250

Winemex 30 / Winemex Blue 30         

Vinkylar

 • För inbyggnad

 • Enkel installation

HITTA RÄTT KÖKSFLÄKT

När du ska välja köksfläkt ska du tänka efter riktigt noga. Du ska fundera på design, storlek, ljudnivån, kapacitet, energiförbrukning, vilka behov köksfläkten ska täcka, vad den ska kunna och var den ska placeras.

Du ska fundera över om köksfläkten ska vara rak, vertikal, frihängande, väggmonterad, integrerad, om motorn
ska sitta inbyggd eller externt och om du vill att luften ska sugas ut eller recirkuleras med hjälp av kolfilter.

Thermex VoiceLink gör din Thermex köksfläkt helt unik

Styr din Thermex köksfläkt genom att enbart använda rösten - det gäller både för fläktens olika hastigheter och belysning. På så sätt får du frihet att använda dina händer till andra saker i köket.

Med hjälp av Google Assistant blir din vardag enklare när du skall betjäna din Thermex köksfläkt. T.ex. när alla har satt sig till bords och är redo att äta men du har glömt att stänga av köksfläkten. Ett enkelt kommando räcker:

”Hey Google, stäng av köksfläkten”.

 

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