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