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

Olie- og boreplatforme

Granzow er leverandør til offshore olie-og gasindustrien i skruekompressorer, trykluft behandling, energivenlige kompressor kontrol og container løsninger.

Vi forhandler også et komplet sortiment af automatiserings produkter, såsom sprængplader, Lucifer Magnetventiler, termostater, ventiler, pneumatiske cylindre. Disse kommer i overensstemmelse med ATEX-direktiverne.

Et omfattende program af effektive pumper som højtrykspumper, membranpumper, slangepumper, mobile pumper.

Komplet serie af vakuumpumper, måleudstyr, lækagesøgning systemer og sputter-systemer.

Se udvalget af vores offshore produkter

}