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

1 @inherits Dynamicweb.Rendering.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 if (settings.DisableImageEngine) 741 { 742 defaultImage = settings.Path; 743 } 744 else 745 { 746 if (settings.ImageDefault != null) 747 { 748 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 749 750 if (settings.Path.GetType() != typeof(string)) 751 { 752 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 753 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 754 } 755 else 756 { 757 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 758 } 759 760 defaultImage += "&AlternativeImage=" + alternativeImage; 761 } 762 763 if (settings.ImageSmall != null) 764 { 765 imageSmall = "data-src-small=\"" + imageEngine; 766 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 767 768 if (settings.Path.GetType() != typeof(string)) 769 { 770 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 771 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 772 } 773 else 774 { 775 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 776 } 777 778 imageSmall += "&alternativeImage=" + alternativeImage; 779 780 imageSmall += "\""; 781 } 782 783 if (settings.ImageMedium != null) 784 { 785 imageMedium = "data-src-medium=\"" + imageEngine; 786 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 787 788 if (settings.Path.GetType() != typeof(string)) 789 { 790 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 791 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 792 } 793 else 794 { 795 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 796 } 797 798 imageMedium += "&alternativeImage=" + alternativeImage; 799 800 imageMedium += "\""; 801 } 802 } 803 804 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 805 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 806 if (!string.IsNullOrEmpty(settings.Title)) 807 { 808 optionalAttributes.Add("alt", settings.Title); 809 optionalAttributes.Add("title", settings.Title); 810 } 811 812 if (settings.DisableLazyLoad) 813 { 814 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 815 } 816 else 817 { 818 <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) /> 819 } 820 } 821 } 822 @using System.Reflection 823 @using Dynamicweb.Rapido.Blocks.Components.General 824 @using Dynamicweb.Rapido.Blocks.Components 825 826 @* Component *@ 827 828 @helper RenderFileField(FileField settings) 829 { 830 var attributes = new Dictionary<string, string>(); 831 if (string.IsNullOrEmpty(settings.Id)) 832 { 833 settings.Id = Guid.NewGuid().ToString("N"); 834 } 835 836 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 837 if (settings.Disabled) { attributes.Add("disabled", "true"); } 838 if (settings.Required) { attributes.Add("required", "true"); } 839 if (settings.Multiple) { attributes.Add("multiple", "true"); } 840 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 841 if (string.IsNullOrEmpty(settings.ChooseFileText)) 842 { 843 settings.ChooseFileText = Translate("Choose file"); 844 } 845 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 846 { 847 settings.NoFilesChosenText = Translate("No files chosen..."); 848 } 849 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 850 851 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 852 853 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 854 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 855 856 attributes.Add("type", "file"); 857 if (settings.Value != null) { attributes.Add("value", settings.Value); } 858 settings.CssClass = "u-full-width " + settings.CssClass; 859 860 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 861 862 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 863 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 864 { 865 <div class="u-full-width"> 866 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 867 @if (settings.Link != null) { 868 <div class="u-pull--right"> 869 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 870 @Render(settings.Link) 871 </div> 872 } 873 </div> 874 875 } 876 877 @if (!string.IsNullOrEmpty(settings.HelpText)) 878 { 879 <small class="form__help-text">@settings.HelpText</small> 880 } 881 882 <div class="form__field-combi file-input u-no-margin dw-mod"> 883 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 884 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 885 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 886 @if (settings.UploadButton != null) 887 { 888 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 889 @Render(settings.UploadButton) 890 } 891 </div> 892 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 893 </div> 894 } 895 @using System.Reflection 896 @using Dynamicweb.Rapido.Blocks.Components.General 897 @using Dynamicweb.Rapido.Blocks.Components 898 @using Dynamicweb.Core 899 @using System.Linq 900 901 @* Component *@ 902 903 @helper RenderDateTimeField(DateTimeField settings) 904 { 905 if (string.IsNullOrEmpty(settings.Id)) 906 { 907 settings.Id = Guid.NewGuid().ToString("N"); 908 } 909 910 var textField = new TextField { 911 Name = settings.Name, 912 Id = settings.Id, 913 Label = settings.Label, 914 HelpText = settings.HelpText, 915 Value = settings.Value, 916 Disabled = settings.Disabled, 917 Required = settings.Required, 918 ErrorMessage = settings.ErrorMessage, 919 CssClass = settings.CssClass, 920 WrapperCssClass = settings.WrapperCssClass, 921 OnChange = settings.OnChange, 922 OnClick = settings.OnClick, 923 Link = settings.Link, 924 ExtraAttributes = settings.ExtraAttributes, 925 // 926 Placeholder = settings.Placeholder 927 }; 928 929 @Render(textField) 930 931 List<string> jsAttributes = new List<string>(); 932 933 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 934 935 if (!string.IsNullOrEmpty(settings.DateFormat)) 936 { 937 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 938 } 939 if (!string.IsNullOrEmpty(settings.MinDate)) 940 { 941 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 942 } 943 if (!string.IsNullOrEmpty(settings.MaxDate)) 944 { 945 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 946 } 947 if (settings.IsInline) 948 { 949 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 950 } 951 if (settings.EnableTime) 952 { 953 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 954 } 955 if (settings.EnableWeekNumbers) 956 { 957 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 958 } 959 960 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 961 962 <script> 963 document.addEventListener("DOMContentLoaded", function () { 964 flatpickr("#@textField.Id", { 965 @string.Join(",", jsAttributes) 966 }); 967 }); 968 </script> 969 } 970 @using System.Reflection 971 @using Dynamicweb.Rapido.Blocks.Components.General 972 @using Dynamicweb.Rapido.Blocks.Components 973 974 @* Component *@ 975 976 @helper RenderTextField(TextField settings) 977 { 978 var attributes = new Dictionary<string, string>(); 979 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 980 { 981 settings.Id = Guid.NewGuid().ToString("N"); 982 } 983 984 /*base settings*/ 985 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 986 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 987 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 988 if (settings.Disabled) { attributes.Add("disabled", "true"); } 989 if (settings.Required) { attributes.Add("required", "true"); } 990 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 991 /*end*/ 992 993 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 994 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 995 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 996 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 997 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 998 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 999 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1000 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1001 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1002 1003 settings.CssClass = "u-full-width " + settings.CssClass; 1004 1005 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1006 1007 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1008 1009 string noMargin = "u-no-margin"; 1010 if (!settings.ReadOnly) { 1011 noMargin = ""; 1012 } 1013 1014 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1015 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1016 { 1017 <div class="u-full-width"> 1018 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1019 @if (settings.Link != null) { 1020 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1021 1022 <div class="u-pull--right"> 1023 @Render(settings.Link) 1024 </div> 1025 } 1026 </div> 1027 1028 } 1029 1030 @if (!string.IsNullOrEmpty(settings.HelpText)) 1031 { 1032 <small class="form__help-text">@settings.HelpText</small> 1033 } 1034 1035 @if (settings.ActionButton != null) 1036 { 1037 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1038 <div class="form__field-combi u-no-margin dw-mod"> 1039 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1040 @Render(settings.ActionButton) 1041 </div> 1042 } 1043 else 1044 { 1045 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1046 } 1047 1048 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1049 </div> 1050 } 1051 @using System.Reflection 1052 @using Dynamicweb.Rapido.Blocks.Components.General 1053 @using Dynamicweb.Rapido.Blocks.Components 1054 1055 @* Component *@ 1056 1057 @helper RenderNumberField(NumberField settings) 1058 { 1059 var attributes = new Dictionary<string, string>(); 1060 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1061 { 1062 settings.Id = Guid.NewGuid().ToString("N"); 1063 } 1064 1065 /*base settings*/ 1066 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1067 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1068 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1069 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1070 if (settings.Required) { attributes.Add("required", "true"); } 1071 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1072 /*end*/ 1073 1074 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1075 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1076 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1077 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1078 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1079 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1080 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1081 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1082 attributes.Add("type", "number"); 1083 1084 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1085 1086 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1087 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1088 { 1089 <div class="u-full-width"> 1090 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1091 @if (settings.Link != null) { 1092 <div class="u-pull--right"> 1093 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1094 @Render(settings.Link) 1095 </div> 1096 } 1097 </div> 1098 1099 } 1100 1101 @if (!string.IsNullOrEmpty(settings.HelpText)) 1102 { 1103 <small class="form__help-text">@settings.HelpText</small> 1104 } 1105 1106 @if (settings.ActionButton != null) 1107 { 1108 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1109 <div class="form__field-combi u-no-margin dw-mod"> 1110 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1111 @Render(settings.ActionButton) 1112 </div> 1113 } 1114 else 1115 { 1116 <div class="form__field-combi u-no-margin dw-mod"> 1117 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1118 </div> 1119 } 1120 1121 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1122 </div> 1123 } 1124 @using System.Reflection 1125 @using Dynamicweb.Rapido.Blocks.Components.General 1126 @using Dynamicweb.Rapido.Blocks.Components 1127 1128 1129 @* Component *@ 1130 1131 @helper RenderTextareaField(TextareaField settings) 1132 { 1133 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1134 string id = settings.Id; 1135 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1136 { 1137 id = Guid.NewGuid().ToString("N"); 1138 } 1139 1140 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1141 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1142 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1143 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1144 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1145 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1146 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1147 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1148 if (settings.Required) { attributes.Add("required", "true"); } 1149 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1150 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1151 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1152 attributes.Add("name", settings.Name); 1153 1154 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1155 1156 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1157 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1158 { 1159 <div class="u-full-width"> 1160 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1161 @if (settings.Link != null) { 1162 <div class="u-pull--right"> 1163 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1164 @Render(settings.Link) 1165 </div> 1166 } 1167 </div> 1168 } 1169 1170 @if (!string.IsNullOrEmpty(settings.HelpText)) 1171 { 1172 <small class="form__help-text">@settings.HelpText</small> 1173 } 1174 1175 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1176 1177 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1178 </div> 1179 } 1180 @using System.Reflection 1181 @using Dynamicweb.Rapido.Blocks.Components.General 1182 @using Dynamicweb.Rapido.Blocks.Components 1183 1184 1185 @* Component *@ 1186 1187 @helper RenderHiddenField(HiddenField settings) { 1188 var attributes = new Dictionary<string, string>(); 1189 attributes.Add("type", "hidden"); 1190 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1191 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1192 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1193 1194 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1195 } 1196 @using System.Reflection 1197 @using Dynamicweb.Rapido.Blocks.Components.General 1198 @using Dynamicweb.Rapido.Blocks.Components 1199 1200 @* Component *@ 1201 1202 @helper RenderCheckboxField(CheckboxField settings) 1203 { 1204 var attributes = new Dictionary<string, string>(); 1205 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1206 { 1207 settings.Id = Guid.NewGuid().ToString("N"); 1208 } 1209 1210 /*base settings*/ 1211 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1212 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1213 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1214 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1215 if (settings.Required) { attributes.Add("required", "true"); } 1216 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1217 /*end*/ 1218 1219 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1220 1221 attributes.Add("type", "checkbox"); 1222 if (settings.Checked) { attributes.Add("checked", "true"); } 1223 settings.CssClass = "form__control " + settings.CssClass; 1224 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1225 1226 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1227 1228 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1229 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1230 @if (!string.IsNullOrEmpty(settings.Label)) 1231 { 1232 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1233 } 1234 1235 @if (settings.Link != null) { 1236 <span> 1237 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1238 @Render(settings.Link) 1239 </span> 1240 } 1241 1242 @if (!string.IsNullOrEmpty(settings.HelpText)) 1243 { 1244 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1245 } 1246 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1247 </div> 1248 } 1249 @using System.Reflection 1250 @using Dynamicweb.Rapido.Blocks.Components.General 1251 @using Dynamicweb.Rapido.Blocks.Components 1252 1253 1254 @* Component *@ 1255 1256 @helper RenderCheckboxListField(CheckboxListField settings) 1257 { 1258 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1259 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1260 { 1261 <div class="u-full-width"> 1262 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1263 @if (settings.Link != null) { 1264 <div class="u-pull--right"> 1265 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1266 @Render(settings.Link) 1267 </div> 1268 } 1269 </div> 1270 1271 } 1272 1273 <div class="u-pull--left"> 1274 @if (!string.IsNullOrEmpty(settings.HelpText)) 1275 { 1276 <small class="form__help-text">@settings.HelpText</small> 1277 } 1278 1279 @foreach (var item in settings.Options) 1280 { 1281 if (settings.Required) 1282 { 1283 item.Required = true; 1284 } 1285 if (settings.Disabled) 1286 { 1287 item.Disabled = true; 1288 } 1289 if (!string.IsNullOrEmpty(settings.Name)) 1290 { 1291 item.Name = settings.Name; 1292 } 1293 if (!string.IsNullOrEmpty(settings.CssClass)) 1294 { 1295 item.CssClass += settings.CssClass; 1296 } 1297 1298 /* value is not supported */ 1299 1300 if (!string.IsNullOrEmpty(settings.OnClick)) 1301 { 1302 item.OnClick += settings.OnClick; 1303 } 1304 if (!string.IsNullOrEmpty(settings.OnChange)) 1305 { 1306 item.OnChange += settings.OnChange; 1307 } 1308 @Render(item) 1309 } 1310 1311 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1312 </div> 1313 1314 </div> 1315 } 1316 @using Dynamicweb.Rapido.Blocks.Components.General 1317 1318 @* Component *@ 1319 1320 @helper RenderSearch(Search settings) 1321 { 1322 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1323 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1324 1325 if (string.IsNullOrEmpty(settings.Id)) 1326 { 1327 settings.Id = Guid.NewGuid().ToString("N"); 1328 } 1329 1330 var resultAttributes = new Dictionary<string, string>(); 1331 1332 if (settings.PageSize != 0) 1333 { 1334 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1335 } 1336 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1337 { 1338 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1339 if (!string.IsNullOrEmpty(groupValue)) 1340 { 1341 resultAttributes.Add("data-selected-group", groupValue); 1342 } 1343 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1344 { 1345 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1346 } 1347 } 1348 resultAttributes.Add("data-force-init", "true"); 1349 if (settings.GoToFirstSearchResultOnEnter) 1350 { 1351 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1352 } 1353 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1354 { 1355 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1356 } 1357 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1358 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1359 1360 if (settings.SecondSearchData != null) 1361 { 1362 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1363 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1364 } 1365 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1366 { 1367 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1368 } 1369 1370 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1371 1372 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1373 1374 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1375 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1376 { 1377 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1378 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1379 } 1380 1381 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1382 1383 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1384 @if (settings.SecondSearchData != null) 1385 { 1386 <div class="search__column search__column--products dw-mod"> 1387 <div class="search__column-header dw-mod">@Translate("Products")</div> 1388 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1389 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1390 { 1391 @Render(new Link { 1392 Title = Translate("View all"), 1393 CssClass = "js-view-all-button u-margin", 1394 Href = settings.SearchData.ResultsPageUrl 1395 }); 1396 } 1397 </div> 1398 <div class="search__column search__column--pages dw-mod"> 1399 <div class="search__column-header">@Translate("Pages")</div> 1400 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1401 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1402 { 1403 @Render(new Link 1404 { 1405 Title = Translate("View all"), 1406 CssClass = "js-view-all-button u-margin", 1407 Href = settings.SecondSearchData.ResultsPageUrl 1408 }); 1409 } 1410 </div> 1411 } 1412 else 1413 { 1414 <div class="search__column search__column--only dw-mod"> 1415 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1416 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1417 { 1418 @Render(new Link { 1419 Title = Translate("View all"), 1420 CssClass = "js-view-all-button u-margin", 1421 Href = settings.SearchData.ResultsPageUrl 1422 }); 1423 } 1424 </div> 1425 } 1426 </div> 1427 1428 @if (settings.SearchButton != null) 1429 { 1430 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1431 if (settings.RenderDefaultSearchIcon) 1432 { 1433 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1434 } 1435 @Render(settings.SearchButton); 1436 } 1437 </div> 1438 } 1439 @using System.Reflection 1440 @using Dynamicweb.Rapido.Blocks.Components.General 1441 @using Dynamicweb.Rapido.Blocks.Components 1442 1443 1444 @* Component *@ 1445 1446 @helper RenderSelectField(SelectField settings) 1447 { 1448 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1449 { 1450 settings.Id = Guid.NewGuid().ToString("N"); 1451 } 1452 1453 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1454 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1455 { 1456 <div class="u-full-width"> 1457 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1458 @if (settings.Link != null) { 1459 <div class="u-pull--right"> 1460 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1461 @Render(settings.Link) 1462 </div> 1463 } 1464 </div> 1465 } 1466 1467 @if (!string.IsNullOrEmpty(settings.HelpText)) 1468 { 1469 <small class="form__help-text">@settings.HelpText</small> 1470 } 1471 1472 @if (settings.ActionButton != null) 1473 { 1474 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1475 <div class="form__field-combi u-no-margin dw-mod"> 1476 @RenderSelectBase(settings) 1477 @Render(settings.ActionButton) 1478 </div> 1479 } 1480 else 1481 { 1482 @RenderSelectBase(settings) 1483 } 1484 1485 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1486 </div> 1487 } 1488 1489 @helper RenderSelectBase(SelectField settings) 1490 { 1491 var attributes = new Dictionary<string, string>(); 1492 1493 /*base settings*/ 1494 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1495 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1496 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1497 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1498 if (settings.Required) { attributes.Add("required", "true"); } 1499 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1500 /*end*/ 1501 1502 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1503 1504 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1505 @if (settings.Default != null) 1506 { 1507 @Render(settings.Default) 1508 } 1509 1510 @foreach (var item in settings.Options) 1511 { 1512 if (settings.Value != null) { 1513 item.Checked = item.Value == settings.Value; 1514 } 1515 @Render(item) 1516 } 1517 </select> 1518 } 1519 @using System.Reflection 1520 @using Dynamicweb.Rapido.Blocks.Components.General 1521 @using Dynamicweb.Rapido.Blocks.Components 1522 1523 @* Component *@ 1524 1525 @helper RenderRadioButtonField(RadioButtonField settings) 1526 { 1527 var attributes = new Dictionary<string, string>(); 1528 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1529 { 1530 settings.Id = Guid.NewGuid().ToString("N"); 1531 } 1532 1533 /*base settings*/ 1534 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1535 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1536 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1537 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1538 if (settings.Required) { attributes.Add("required", "true"); } 1539 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1540 /*end*/ 1541 1542 attributes.Add("type", "radio"); 1543 if (settings.Checked) { attributes.Add("checked", "true"); } 1544 settings.CssClass = "form__control " + settings.CssClass; 1545 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1546 1547 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1548 1549 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1550 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1551 @if (!string.IsNullOrEmpty(settings.Label)) 1552 { 1553 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1554 } 1555 @if (!string.IsNullOrEmpty(settings.HelpText)) 1556 { 1557 <small class="form__help-text">@settings.HelpText</small> 1558 } 1559 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1560 </div> 1561 } 1562 @using System.Reflection 1563 @using Dynamicweb.Rapido.Blocks.Components.General 1564 @using Dynamicweb.Rapido.Blocks.Components 1565 1566 1567 @* Component *@ 1568 1569 @helper RenderRadioButtonListField(RadioButtonListField settings) 1570 { 1571 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1572 1573 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1574 @if (!string.IsNullOrEmpty(settings.Label)) 1575 { 1576 <label>@settings.Label</label> 1577 } 1578 @if (!string.IsNullOrEmpty(settings.HelpText)) 1579 { 1580 <small class="form__help-text">@settings.HelpText</small> 1581 } 1582 1583 @foreach (var item in settings.Options) 1584 { 1585 if (settings.Required) 1586 { 1587 item.Required = true; 1588 } 1589 if (settings.Disabled) 1590 { 1591 item.Disabled = true; 1592 } 1593 if (!string.IsNullOrEmpty(settings.Name)) 1594 { 1595 item.Name = settings.Name; 1596 } 1597 if (settings.Value != null && settings.Value == item.Value) 1598 { 1599 item.Checked = true; 1600 } 1601 if (!string.IsNullOrEmpty(settings.OnClick)) 1602 { 1603 item.OnClick += settings.OnClick; 1604 } 1605 if (!string.IsNullOrEmpty(settings.OnChange)) 1606 { 1607 item.OnChange += settings.OnChange; 1608 } 1609 if (!string.IsNullOrEmpty(settings.CssClass)) 1610 { 1611 item.CssClass += settings.CssClass; 1612 } 1613 @Render(item) 1614 } 1615 1616 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1617 </div> 1618 } 1619 @using System.Reflection 1620 @using Dynamicweb.Rapido.Blocks.Components.General 1621 @using Dynamicweb.Rapido.Blocks.Components 1622 1623 1624 @* Component *@ 1625 1626 @helper RenderNotificationMessage(NotificationMessage settings) 1627 { 1628 if (!string.IsNullOrEmpty(settings.Message)) 1629 { 1630 var attributes = new Dictionary<string, string>(); 1631 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1632 1633 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1634 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1635 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1636 1637 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1638 @if (settings.Icon != null) { 1639 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1640 @Render(settings.Icon) 1641 } else { 1642 @settings.Message 1643 } 1644 </div> 1645 } 1646 } 1647 @using Dynamicweb.Rapido.Blocks.Components.General 1648 1649 1650 @* Component *@ 1651 1652 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1653 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1654 1655 <div class="@settings.CssClass dw-mod js-handlebars-root" id="@settings.Id" data-template="@settings.ScriptTemplate" data-json-feed="@settings.FeedUrl" data-init-onload="@settings.InitOnLoad.ToString()" data-preloader="@settings.Preloader" @preRender> 1656 @if (settings.SubBlocks != null) { 1657 @RenderBlockList(settings.SubBlocks) 1658 } 1659 </div> 1660 } 1661 @using System.Reflection 1662 @using Dynamicweb.Rapido.Blocks.Components.General 1663 @using Dynamicweb.Rapido.Blocks.Components 1664 @using System.Text.RegularExpressions 1665 1666 1667 @* Component *@ 1668 1669 @helper RenderSticker(Sticker settings) { 1670 if (!String.IsNullOrEmpty(settings.Title)) { 1671 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1672 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1673 1674 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1675 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1676 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1677 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1678 optionalAttributes.Add("style", styleTag); 1679 } 1680 1681 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1682 } 1683 } 1684 1685 @using System.Reflection 1686 @using Dynamicweb.Rapido.Blocks.Components.General 1687 @using Dynamicweb.Rapido.Blocks.Components 1688 1689 1690 @* Component *@ 1691 1692 @helper RenderStickersCollection(StickersCollection settings) 1693 { 1694 if (settings.Stickers.Count > 0) 1695 { 1696 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1697 1698 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1699 @foreach (Sticker sticker in settings.Stickers) 1700 { 1701 @Render(sticker) 1702 } 1703 </div> 1704 } 1705 } 1706 1707 @using Dynamicweb.Rapido.Blocks.Components.General 1708 1709 1710 @* Component *@ 1711 1712 @helper RenderForm(Form settings) { 1713 if (settings != null) 1714 { 1715 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1716 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1717 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1718 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1719 var enctypes = new Dictionary<string, string> 1720 { 1721 { "multipart", "multipart/form-data" }, 1722 { "text", "text/plain" }, 1723 { "application", "application/x-www-form-urlencoded" } 1724 }; 1725 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1726 optionalAttributes.Add("method", settings.Method.ToString()); 1727 1728 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1729 { 1730 @settings.FormStartMarkup 1731 } 1732 else 1733 { 1734 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1735 } 1736 1737 foreach (var field in settings.GetFields()) 1738 { 1739 @Render(field) 1740 } 1741 1742 @:</form> 1743 } 1744 } 1745 @using System.Reflection 1746 @using Dynamicweb.Rapido.Blocks.Components.General 1747 @using Dynamicweb.Rapido.Blocks.Components 1748 1749 1750 @* Component *@ 1751 1752 @helper RenderText(Text settings) 1753 { 1754 @settings.Content 1755 } 1756 @using System.Reflection 1757 @using Dynamicweb.Rapido.Blocks.Components.General 1758 @using Dynamicweb.Rapido.Blocks.Components 1759 1760 1761 @* Component *@ 1762 1763 @helper RenderContentModule(ContentModule settings) { 1764 if (!string.IsNullOrEmpty(settings.Content)) 1765 { 1766 @settings.Content 1767 } 1768 } 1769 @using System.Reflection 1770 @using Dynamicweb.Rapido.Blocks.Components.General 1771 @using Dynamicweb.Rapido.Blocks.Components 1772 1773 1774 @* Component *@ 1775 1776 @helper RenderModal(Modal settings) { 1777 if (settings != null) 1778 { 1779 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1780 1781 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1782 1783 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1784 1785 <div class="modal-container"> 1786 @if (!settings.DisableDarkOverlay) 1787 { 1788 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1789 } 1790 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1791 @if (settings.Heading != null) 1792 { 1793 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1794 { 1795 <div class="modal__header"> 1796 @Render(settings.Heading) 1797 </div> 1798 } 1799 } 1800 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1801 @if (!string.IsNullOrEmpty(settings.BodyText)) 1802 { 1803 @settings.BodyText 1804 } 1805 @if (settings.BodyTemplate != null) 1806 { 1807 @settings.BodyTemplate 1808 } 1809 @{ 1810 var actions = settings.GetActions(); 1811 } 1812 </div> 1813 @if (actions.Length > 0) 1814 { 1815 <div class="modal__footer"> 1816 @foreach (var action in actions) 1817 { 1818 if (Pageview.Device.ToString() != "Mobile") { 1819 action.CssClass += " u-no-margin"; 1820 } else { 1821 action.CssClass += " u-full-width u-margin-bottom"; 1822 } 1823 1824 @Render(action) 1825 } 1826 </div> 1827 } 1828 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1829 </div> 1830 </div> 1831 } 1832 } 1833 @using Dynamicweb.Rapido.Blocks.Components.General 1834 1835 @* Component *@ 1836 1837 @helper RenderMediaListItem(MediaListItem settings) 1838 { 1839 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1840 @if (!string.IsNullOrEmpty(settings.Label)) 1841 { 1842 if (!string.IsNullOrEmpty(settings.Link)) 1843 { 1844 @Render(new Link 1845 { 1846 Href = settings.Link, 1847 CssClass = "media-list-item__sticker dw-mod", 1848 ButtonLayout = ButtonLayout.None, 1849 Title = settings.Label, 1850 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1851 }) 1852 } 1853 else if (!string.IsNullOrEmpty(settings.OnClick)) 1854 { 1855 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1856 <span class="u-uppercase">@settings.Label</span> 1857 </span> 1858 } 1859 else 1860 { 1861 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1862 <span class="u-uppercase">@settings.Label</span> 1863 </span> 1864 } 1865 } 1866 <div class="media-list-item__wrap"> 1867 <div class="media-list-item__info dw-mod"> 1868 <div class="media-list-item__header dw-mod"> 1869 @if (!string.IsNullOrEmpty(settings.Title)) 1870 { 1871 if (!string.IsNullOrEmpty(settings.Link)) 1872 { 1873 @Render(new Link 1874 { 1875 Href = settings.Link, 1876 CssClass = "media-list-item__name dw-mod", 1877 ButtonLayout = ButtonLayout.None, 1878 Title = settings.Title, 1879 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1880 }) 1881 } 1882 else if (!string.IsNullOrEmpty(settings.OnClick)) 1883 { 1884 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1885 } 1886 else 1887 { 1888 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1889 } 1890 } 1891 1892 @if (!string.IsNullOrEmpty(settings.Status)) 1893 { 1894 <div class="media-list-item__state dw-mod">@settings.Status</div> 1895 } 1896 </div> 1897 @{ 1898 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1899 } 1900 1901 @Render(settings.InfoTable) 1902 </div> 1903 <div class="media-list-item__actions dw-mod"> 1904 <div class="media-list-item__actions-list dw-mod"> 1905 @{ 1906 var actions = settings.GetActions(); 1907 1908 foreach (ButtonBase action in actions) 1909 { 1910 action.ButtonLayout = ButtonLayout.None; 1911 action.CssClass += " media-list-item__action link"; 1912 1913 @Render(action) 1914 } 1915 } 1916 </div> 1917 1918 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1919 { 1920 settings.SelectButton.CssClass += " u-no-margin"; 1921 1922 <div class="media-list-item__action-button"> 1923 @Render(settings.SelectButton) 1924 </div> 1925 } 1926 </div> 1927 </div> 1928 </div> 1929 } 1930 @using Dynamicweb.Rapido.Blocks.Components.General 1931 @using Dynamicweb.Rapido.Blocks.Components 1932 1933 @helper RenderTable(Table settings) 1934 { 1935 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1936 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1937 1938 var enumToClasses = new Dictionary<TableDesign, string> 1939 { 1940 { TableDesign.Clean, "table--clean" }, 1941 { TableDesign.Bordered, "table--bordered" }, 1942 { TableDesign.Striped, "table--striped" }, 1943 { TableDesign.Hover, "table--hover" }, 1944 { TableDesign.Compact, "table--compact" }, 1945 { TableDesign.Condensed, "table--condensed" }, 1946 { TableDesign.NoTopBorder, "table--no-top-border" } 1947 }; 1948 string tableDesignClass = ""; 1949 if (settings.Design != TableDesign.None) 1950 { 1951 tableDesignClass = enumToClasses[settings.Design]; 1952 } 1953 1954 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1955 1956 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1957 1958 <table @ComponentMethods.AddAttributes(resultAttributes)> 1959 @if (settings.Header != null) 1960 { 1961 <thead> 1962 @Render(settings.Header) 1963 </thead> 1964 } 1965 <tbody> 1966 @foreach (var row in settings.Rows) 1967 { 1968 @Render(row) 1969 } 1970 </tbody> 1971 @if (settings.Footer != null) 1972 { 1973 <tfoot> 1974 @Render(settings.Footer) 1975 </tfoot> 1976 } 1977 </table> 1978 } 1979 @using Dynamicweb.Rapido.Blocks.Components.General 1980 @using Dynamicweb.Rapido.Blocks.Components 1981 1982 @helper RenderTableRow(TableRow settings) 1983 { 1984 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1985 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1986 1987 var enumToClasses = new Dictionary<TableRowDesign, string> 1988 { 1989 { TableRowDesign.NoBorder, "table__row--no-border" }, 1990 { TableRowDesign.Border, "table__row--border" }, 1991 { TableRowDesign.TopBorder, "table__row--top-line" }, 1992 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1993 { TableRowDesign.Solid, "table__row--solid" } 1994 }; 1995 1996 string tableRowDesignClass = ""; 1997 if (settings.Design != TableRowDesign.None) 1998 { 1999 tableRowDesignClass = enumToClasses[settings.Design]; 2000 } 2001 2002 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2003 2004 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2005 2006 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2007 @foreach (var cell in settings.Cells) 2008 { 2009 if (settings.IsHeaderRow) 2010 { 2011 cell.IsHeader = true; 2012 } 2013 @Render(cell) 2014 } 2015 </tr> 2016 } 2017 @using Dynamicweb.Rapido.Blocks.Components.General 2018 @using Dynamicweb.Rapido.Blocks.Components 2019 @using Dynamicweb.Core 2020 2021 @helper RenderTableCell(TableCell settings) 2022 { 2023 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2024 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2025 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2026 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2027 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2028 2029 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2030 2031 string tagName = settings.IsHeader ? "th" : "td"; 2032 2033 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2034 @settings.Content 2035 @("</" + tagName + ">"); 2036 } 2037 @using System.Linq 2038 @using Dynamicweb.Rapido.Blocks.Components.General 2039 2040 @* Component *@ 2041 2042 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2043 { 2044 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2045 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2046 2047 if (settings.NumberOfPages > 1) 2048 { 2049 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2050 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2051 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2052 2053 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2054 @if (settings.ShowPagingInfo) 2055 { 2056 <div class="pager__info dw-mod"> 2057 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2058 </div> 2059 } 2060 <ul class="pager__list dw-mod"> 2061 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2062 { 2063 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2064 } 2065 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2066 { 2067 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2068 } 2069 @if (settings.GetPages().Any()) 2070 { 2071 foreach (var page in settings.GetPages()) 2072 { 2073 @Render(page) 2074 } 2075 } 2076 else 2077 { 2078 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2079 { 2080 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2081 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2082 } 2083 } 2084 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2085 { 2086 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2087 } 2088 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2089 { 2090 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2091 } 2092 </ul> 2093 </div> 2094 } 2095 } 2096 2097 @helper RenderPaginationItem(PaginationItem settings) 2098 { 2099 if (settings.Icon == null) 2100 { 2101 settings.Icon = new Icon(); 2102 } 2103 2104 settings.Icon.Label = settings.Label; 2105 <li class="pager__btn dw-mod"> 2106 @if (settings.IsActive) 2107 { 2108 <span class="pager__num pager__num--current dw-mod"> 2109 @Render(settings.Icon) 2110 </span> 2111 } 2112 else 2113 { 2114 <a href="@settings.Link" class="pager__num dw-mod"> 2115 @Render(settings.Icon) 2116 </a> 2117 } 2118 </li> 2119 } 2120 2121 2122 @using Dynamicweb.Rapido.Blocks.Components.General 2123 2124 @using Ppdw.Common; 2125 2126 @functions { 2127 public string PerfionImagePrefix(int width, int height) 2128 { 2129 return string.Format("{0}/Perfion/Image.aspx?size={1}x{2}&format=png&id=", GlobalSettingsHelper.GetValue(PicoGlobalSettingsNames.PerfionWebApiUrl), width, height); 2130 } 2131 } 2132 @using System.Xml.Linq; 2133 @using Ppdw.Common; 2134 @using System.Diagnostics; 2135 @using System.Text; 2136 @using Dynamicweb.Configuration; 2137 2138 @functions { 2139 2140 } 2141 2142 @helper RenderCraneArmIllustrationCollection(IEnumerable<int> perfionIds) 2143 { 2144 if (0 < perfionIds.Count()) 2145 { 2146 2147 2148 //var variantString = Convert.ToBase64String(Encoding.UTF8.GetBytes("[" + string.Join(",", variantJsObjects) + "]")); 2149 <canvas id="illustration-canvas" 2150 data-variants='@string.Join(",", perfionIds)' 2151 style="opacity: 0;width: 50%; height: 50%" 2152 @*data-scaling="@scaling" 2153 width="@(widestBase + widestJointSum + (mostJoints * (5 /* joint gap */ * scaling)) + (40 /* fly-jib indentation */ * scaling) + 10 /* image margin*/)" 2154 height="@(variantJsObjects.Count() * (120 * scaling))"*@ 2155 ></canvas> 2156 2157 <img id="illustration-img" style="width:50%;height:50%;" /> 2158 } 2159 } 2160 @using Ppdw.Common; 2161 2162 @functions { 2163 public string PerfionFilePrefix(Guid id) 2164 { 2165 return string.Format("{0}/Perfion/File.aspx?id={1}", GlobalSettingsHelper.GetValue(PicoGlobalSettingsNames.PerfionWebApiUrl), id); 2166 } 2167 } 2168 @using Dynamicweb.Rapido.Blocks.Components 2169 @using Dynamicweb.Rapido.Blocks.Components.General 2170 @using Dynamicweb.Rapido.Blocks 2171 2172 2173 @* Custom Component 2174 2175 * Added u-reset-position to secondary filter * 2176 *@ 2177 2178 @helper RenderImageCustom(Image settings) 2179 { 2180 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 2181 { 2182 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 2183 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 2184 2185 if (settings.Caption != null) 2186 { 2187 @:<div> 2188 } 2189 2190 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 2191 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 2192 2193 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 2194 <div class="image-filter image-filter--@secondaryFilterClass u-reset-position dw-mod"> 2195 @if (settings.Link != null) 2196 { 2197 <a href="@settings.Link"> 2198 @RenderTheImage(settings) 2199 </a> 2200 } 2201 else 2202 { 2203 @RenderTheImage(settings) 2204 } 2205 </div> 2206 </div> 2207 2208 if (settings.Caption != null) 2209 { 2210 <span class="image-caption dw-mod">@settings.Caption</span> 2211 @:</div> 2212 } 2213 } 2214 else 2215 { 2216 if (settings.Caption != null) 2217 { 2218 @:<div> 2219 } 2220 if (!string.IsNullOrEmpty(settings.Link)) 2221 { 2222 <a href="@settings.Link"> 2223 @RenderTheImage(settings) 2224 </a> 2225 } 2226 else 2227 { 2228 @RenderTheImage(settings) 2229 } 2230 2231 if (settings.Caption != null) 2232 { 2233 <span class="image-caption dw-mod">@settings.Caption</span> 2234 @:</div> 2235 } 2236 } 2237 } 2238 2239 2240 @* Include the basic, re-used, paragraph initializer *@ 2241 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2242 @using Dynamicweb.Frontend 2243 @using Dynamicweb.Rapido.Blocks.Components.General 2244 @using Dynamicweb.Rapido.Blocks.Components 2245 2246 @functions { 2247 public class ContentParagraph 2248 { 2249 public string Title { get; set; } 2250 public Image Image { get; set; } 2251 public string Text { get; set; } 2252 public string Link { get; set; } 2253 public bool SetImageAsBackground { get; set; } 2254 public bool HideOuterPadding { get; set; } 2255 public string InnerPaddingCss { get; set; } 2256 public string CardCss { get; set; } 2257 public string ButtonWrapperCss { get; set; } 2258 public string Layout { get; set; } 2259 public string Module { get; set; } 2260 public Link ButtonPrimary { get; set; } 2261 public Link ButtonSecondary { get; set; } 2262 } 2263 } 2264 2265 @helper RenderParagraph(ItemViewModel item, bool renderModule = true) 2266 { 2267 if (item != null) { 2268 string layout = item.GetList("ContentPositions").SelectedValue; 2269 2270 string paragraphClasses = ""; 2271 string paragraphWidth = !String.IsNullOrEmpty(item.GetString("Width")) ? item.GetList("Width").SelectedValue : "12"; 2272 paragraphClasses += " grid__col-lg-" + paragraphWidth + " grid__col-md-" + paragraphWidth + " grid__col-sm-" + paragraphWidth; 2273 if (item.GetList("WidthMobile").SelectedValue == "hide") 2274 { 2275 paragraphClasses += " u-hidden-xs"; 2276 } 2277 else 2278 { 2279 paragraphClasses += " grid__col-xs-" + item.GetList("WidthMobile").SelectedValue; 2280 } 2281 paragraphClasses += item.GetBoolean("HidePadding") ? " paragraph-container--no-padding" : ""; 2282 paragraphClasses += layout == "middle-center" || layout == "middle-left" ? " u-middle-horizontal grid--justify-center grid--align-self-center" : ""; 2283 2284 //Alternative Design Layout 2285 var designLayout = Model.Item.GetItem("CustomSettings") != null ? Model.Item.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.Item.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 2286 paragraphClasses += !String.IsNullOrEmpty(designLayout) ? designLayout : ""; 2287 2288 string title = item.GetBoolean("ShowTitle") ? item.GetString("Title") : ""; 2289 string cardClass = item.GetBoolean("ShowAsCard") ? "paragraph-card" : ""; 2290 string buttonSpacing = ""; 2291 string buttonAlignment = layout == "all-centered" || layout == "middle-center" ? "grid--justify-center" : ""; 2292 2293 string image = item.GetFile("Image") != null ? item.GetFile("Image").ToString() + "&" + item.GetFile("Image").GetFocalPointParameters() : ""; 2294 string imageNoUrlEncoded = item.GetFile("Image") != null ? item.GetFile("Image").Path : ""; 2295 2296 int cropMode = !String.IsNullOrEmpty(Converter.ToString(item.GetList("ImageCrop"))) ? Convert.ToInt32(item.GetList("ImageCrop").SelectedValue) : 0; 2297 ImageStyle imageStyle = item.GetList("ImageStyle").SelectedValue == "ball" ? ImageStyle.Ball : ImageStyle.None; 2298 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; 2299 if (primaryButtonLayout == ButtonLayout.Link) 2300 { 2301 primaryButtonLayout = ButtonLayout.LinkClean; 2302 } 2303 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; 2304 if (secondaryButtonLayout == ButtonLayout.Link) 2305 { 2306 secondaryButtonLayout = ButtonLayout.LinkClean; 2307 } 2308 ImageFilter primaryImageFilter = !string.IsNullOrEmpty(item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2309 ImageFilter secondaryImageFilter = !string.IsNullOrEmpty(item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2310 string imageFilterColorCode = item.GetString("ColorForTheFilter").StartsWith("#") && primaryImageFilter == ImageFilter.Colorize ? GenerateRgba(item.GetString("ColorForTheFilter"), 0.3) : ""; 2311 bool setImageAsBackground = item.GetList("ImageStyle").SelectedValue.ToLower() == "background" ? true : false; 2312 string altText = item.GetString("Title"); 2313 2314 // Get metadata for file 2315 Dynamicweb.Content.Files.Metadata.Meta m = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(Dynamicweb.Context.Current.Server.MapPath(imageNoUrlEncoded)); 2316 2317 if (string.IsNullOrEmpty(altText)) 2318 { 2319 if (m != null) 2320 { 2321 var lang = PageView.Current().Area.CultureInfo.TwoLetterISOLanguageName; 2322 switch (lang) 2323 { 2324 case "da": 2325 altText = m.GetValue("alttext_dk"); 2326 break; 2327 case "de": 2328 altText = m.GetValue("alttext_de"); 2329 break; 2330 case "fr": 2331 altText = m.GetValue("alttext_fr"); 2332 break; 2333 default: 2334 altText = m.GetValue("alttext"); 2335 break; 2336 } 2337 } 2338 } 2339 2340 Image paragraphImage = null; 2341 if (!String.IsNullOrEmpty(image)) 2342 { 2343 paragraphImage = new Image 2344 { 2345 Path = image, 2346 Link = item.GetString("Link"), 2347 FilterPrimary = primaryImageFilter, 2348 FilterSecondary = secondaryImageFilter, 2349 FilterColor = imageFilterColorCode, 2350 Style = imageStyle, 2351 Title = altText, 2352 ImageDefault = new ImageSettings 2353 { 2354 Crop = cropMode, 2355 Height = 845, 2356 Width = 1920 2357 }, 2358 ImageMedium = new ImageSettings 2359 { 2360 Crop = cropMode, 2361 Height = 450, 2362 Width = 1024 2363 }, 2364 ImageSmall = new ImageSettings 2365 { 2366 Crop = cropMode, 2367 Height = 544, 2368 Width = 640 2369 } 2370 }; 2371 } 2372 2373 ContentParagraph paragraph = new ContentParagraph 2374 { 2375 Title = title, 2376 Text = item.GetString("Text"), 2377 Image = paragraphImage, 2378 Link = item.GetString("Link"), 2379 Module = !String.IsNullOrEmpty(Model.GetModuleOutput()) && renderModule ? Model.GetModuleOutput() : "", 2380 InnerPaddingCss = item.GetList("InnerPadding") != null ? "paragraph-container__body--padding-" + item.GetList("InnerPadding").SelectedValue : "", 2381 CardCss = cardClass, 2382 HideOuterPadding = item.GetBoolean("HidePadding"), 2383 SetImageAsBackground = item.GetList("ImageStyle").SelectedValue.ToLower() == "background" ? true : false, 2384 ButtonWrapperCss = buttonSpacing + buttonAlignment, 2385 Layout = layout 2386 }; 2387 2388 if (!String.IsNullOrEmpty(item.GetString("Link"))) 2389 { 2390 paragraph.ButtonPrimary = new Link 2391 { 2392 Href = item.GetString("Link"), 2393 Title = item.GetString("LinkText"), 2394 ButtonLayout = primaryButtonLayout, 2395 CssClass = "u-no-margin" 2396 }; 2397 2398 if (!String.IsNullOrEmpty(item.GetString("SecondaryLink"))) { 2399 paragraph.ButtonPrimary.CssClass = ""; 2400 } 2401 } 2402 2403 if (!String.IsNullOrEmpty(item.GetString("SecondaryLink"))) 2404 { 2405 if (!String.IsNullOrEmpty(item.GetString("Link"))) 2406 { 2407 paragraph.ButtonPrimary.CssClass += " u-margin-right--lg"; 2408 } 2409 2410 paragraph.ButtonSecondary = new Link 2411 { 2412 Href = item.GetString("SecondaryLink"), 2413 Title = item.GetString("SecondaryLinkText"), 2414 ButtonLayout = secondaryButtonLayout 2415 }; 2416 } 2417 2418 <div class="paragraph-container @paragraphClasses dw-mod"> 2419 @if (setImageAsBackground == true && paragraphImage != null) 2420 { 2421 paragraphImage.CssClass = "background-image__cover"; 2422 2423 <div class="background-image dw-mod"> 2424 <div class="background-image__wrapper dw-mod"> 2425 @Render(paragraphImage) 2426 </div> 2427 </div> 2428 } 2429 @{ 2430 switch (layout) 2431 { 2432 case "title-top": 2433 @RenderLayoutTitleTop(paragraph) 2434 break; 2435 case "image-left": 2436 @RenderLayoutImageLeft(paragraph) 2437 break; 2438 case "image-right": 2439 @RenderLayoutImageRight(paragraph) 2440 break; 2441 case "image-centered": 2442 @RenderLayoutImageCentered(paragraph) 2443 break; 2444 case "all-centered": 2445 @RenderLayoutAllCentered(paragraph) 2446 break; 2447 case "middle-center": 2448 case "middle-left": 2449 @RenderLayoutMiddle(paragraph) 2450 break; 2451 default: 2452 @RenderLayoutImageTop(paragraph) 2453 break; 2454 } 2455 } 2456 </div> 2457 } 2458 } 2459 2460 2461 @helper RenderLayoutTitleTop(ContentParagraph settings) 2462 { 2463 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2464 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2465 @if (!settings.SetImageAsBackground && settings.Image != null) 2466 { 2467 <div class="u-margin-bottom--lg"> 2468 @Render(settings.Image) 2469 </div> 2470 } 2471 @Render(new Text { Content = settings.Text}) 2472 @Render(new ContentModule { Content = settings.Module }) 2473 2474 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2475 { 2476 <div class="grid__cell"> 2477 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2478 @Render(settings.ButtonPrimary) 2479 @Render(settings.ButtonSecondary) 2480 </div> 2481 </div> 2482 } 2483 </div> 2484 } 2485 2486 @helper RenderLayoutImageLeft(ContentParagraph settings) 2487 { 2488 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2489 <div class="grid grid--external-bleed"> 2490 @if (!settings.SetImageAsBackground && settings.Image != null) 2491 { 2492 <div class="grid__col-3"> 2493 @Render(settings.Image) 2494 </div> 2495 } 2496 <div class="grid__col-9 @settings.InnerPaddingCss dw-mod"> 2497 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2498 @Render(new Text { Content = settings.Text }) 2499 @Render(new ContentModule { Content = settings.Module }) 2500 2501 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2502 { 2503 <div class="grid__cell"> 2504 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2505 @Render(settings.ButtonPrimary) 2506 @Render(settings.ButtonSecondary) 2507 </div> 2508 </div> 2509 } 2510 </div> 2511 </div> 2512 </div> 2513 } 2514 2515 @helper RenderLayoutImageRight(ContentParagraph settings) 2516 { 2517 <div class="grid__cell @settings.CardCss"> 2518 <div class="grid grid--external-bleed"> 2519 <div class="grid__col-9 @settings.InnerPaddingCss dw-mod"> 2520 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2521 @Render(new Text { Content = settings.Text }) 2522 @Render(new ContentModule { Content = settings.Module }) 2523 2524 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2525 { 2526 <div class="grid__cell"> 2527 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2528 @Render(settings.ButtonPrimary) 2529 @Render(settings.ButtonSecondary) 2530 </div> 2531 </div> 2532 } 2533 </div> 2534 @if (!settings.SetImageAsBackground && settings.Image != null) 2535 { 2536 <div class="grid__col-3"> 2537 @Render(settings.Image) 2538 </div> 2539 } 2540 </div> 2541 </div> 2542 } 2543 2544 @helper RenderLayoutImageCentered(ContentParagraph settings) 2545 { 2546 <div class="grid__cell @settings.CardCss dw-mod"> 2547 2548 <div class="u-ta-center"> 2549 @if (!settings.SetImageAsBackground && settings.Image != null) 2550 { 2551 <div class="u-margin-bottom--lg u-inline-block"> 2552 @Render(settings.Image) 2553 </div> 2554 } 2555 </div> 2556 <div class="@settings.InnerPaddingCss dw-mod"> 2557 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2558 @Render(new Text { Content = settings.Text }) 2559 @Render(new ContentModule { Content = settings.Module }) 2560 2561 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2562 { 2563 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2564 @Render(settings.ButtonPrimary) 2565 @Render(settings.ButtonSecondary) 2566 </div> 2567 } 2568 </div> 2569 </div> 2570 } 2571 2572 @helper RenderLayoutAllCentered(ContentParagraph settings) 2573 { 2574 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2575 2576 <div class="u-ta-center"> 2577 @if (!settings.SetImageAsBackground && settings.Image != null) 2578 { 2579 <div class="u-margin-bottom--lg u-inline-block"> 2580 @Render(settings.Image) 2581 </div> 2582 } 2583 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2584 @Render(new Text { Content = settings.Text }) 2585 @Render(new ContentModule { Content = settings.Module }) 2586 </div> 2587 2588 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2589 { 2590 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2591 @Render(settings.ButtonPrimary) 2592 @Render(settings.ButtonSecondary) 2593 </div> 2594 } 2595 </div> 2596 } 2597 2598 @helper RenderLayoutMiddle(ContentParagraph settings) 2599 { 2600 <div> 2601 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2602 2603 <div class="@(settings.Layout == "middle-center" ? "u-ta-center" : "")"> 2604 @if (!settings.SetImageAsBackground && settings.Image != null) 2605 { 2606 <div class="u-margin-bottom--lg u-inline-block"> 2607 @Render(settings.Image) 2608 </div> 2609 } 2610 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2611 @Render(new Text { Content = settings.Text }) 2612 @Render(new ContentModule { Content = settings.Module }) 2613 </div> 2614 2615 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2616 { 2617 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2618 @Render(settings.ButtonPrimary) 2619 @Render(settings.ButtonSecondary) 2620 </div> 2621 } 2622 </div> 2623 </div> 2624 } 2625 2626 @helper RenderLayoutImageTop(ContentParagraph settings) 2627 { 2628 <div class="grid__cell @settings.CardCss"> 2629 @if (!settings.SetImageAsBackground && settings.Image != null) 2630 { 2631 <div class="u-margin-bottom--lg"> 2632 @Render(settings.Image) 2633 </div> 2634 } 2635 2636 <div class="@settings.InnerPaddingCss dw-mod"> 2637 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2638 @Render(new Text { Content = settings.Text }) 2639 @Render(new ContentModule { Content = settings.Module }) 2640 2641 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2642 { 2643 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2644 @Render(settings.ButtonPrimary) 2645 @Render(settings.ButtonSecondary) 2646 </div> 2647 } 2648 </div> 2649 </div> 2650 } 2651 2652 2653 @{ 2654 string fontColor = !string.IsNullOrEmpty(Model.Item.GetString("FontColor")) && !Model.Item.GetString("FontColor").StartsWith("#") ? "u-" + Model.Item.GetString("FontColor").Replace(" ", "-").ToLower() : ""; 2655 string backgroundColor = !string.IsNullOrEmpty(Model.Item.GetString("BackgroundColor")) && !Model.Item.GetString("BackgroundColor").StartsWith("#") ? "u-" + Model.Item.GetString("BackgroundColor").Replace(" ", "-").ToLower() + "--bg" : ""; 2656 string colorSettings = Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "style=\"" : ""; 2657 string fontColorHex = Model.Item.GetString("FontColor").StartsWith("#") ? "color: " + Model.Item.GetString("FontColor") + ";" : ""; 2658 string backgroundColorHex = Model.Item.GetString("BackgroundColor").StartsWith("#") ? "background-color: " + Model.Item.GetString("BackgroundColor") + ";" : ""; 2659 colorSettings += fontColorHex; 2660 colorSettings += backgroundColorHex; 2661 colorSettings += Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "\"" : ""; 2662 2663 string paragraphContainerClasses = ""; 2664 string containerClasses = ""; 2665 string gridClasses = ""; 2666 2667 string spacingSize = Model.Item.GetList("Spacing") != null && Model.Item.GetList("Spacing").SelectedValue != "" ? Model.Item.GetList("Spacing").SelectedValue : "lg"; 2668 string placeHolderImage = "/Files/Images/placeholder.gif"; 2669 int columnCount = 0; 2670 int paragraphCount = 0; 2671 int totalParagraphs = Model.Item.GetItems("Paragraph").Count; 2672 int totalSlides = 1; 2673 2674 switch (Model.Item.GetList("Width").SelectedValue) 2675 { 2676 case "center": 2677 containerClasses += "center-container paragraph-container "; 2678 paragraphContainerClasses += " " + fontColor + " " + backgroundColor; 2679 break; 2680 case "full": 2681 containerClasses += fontColor + " " + backgroundColor + " "; 2682 paragraphContainerClasses += "paragraph-container--full-width "; 2683 break; 2684 case "combi": 2685 paragraphContainerClasses += "paragraph-container--full-width " + fontColor + " " + backgroundColor + " "; 2686 containerClasses += "center-container paragraph-container "; 2687 break; 2688 default: 2689 paragraphContainerClasses += "center-container "; 2690 break; 2691 } 2692 2693 if (spacingSize == "none") 2694 { 2695 containerClasses += "paragraph-container--spacing-none "; 2696 } 2697 2698 //Background 2699 string containerBackgroundImage = ""; 2700 string containerBackgroundImagePure = ""; 2701 string containerBackgroundImageLarge = ""; 2702 string containerBackgroundImageMedium = ""; 2703 string containerBackgroundImageSmall = ""; 2704 string containerBackgroundAltText = ""; 2705 2706 string focalPointParameters = Model.Item.GetFile("BackgroundImage") != null ? "&" + Model.Item.GetFile("BackgroundImage").GetFocalPointParameters() : ""; 2707 2708 string containerBackgroundImageFilterColor = Model.Item.GetList("ColorForTheFilter") != null ? Model.Item.GetString("ColorForTheFilter").Replace(" ", "-").ToLower() : "none"; 2709 string containerBackgroundImageFilterPrimary = Model.Item.GetList("ImageFilterPrimary") != null ? Model.Item.GetList("ImageFilterPrimary").SelectedValue : "none"; 2710 string containerBackgroundImageFilterSecondary = Model.Item.GetList("ImageFilterSecondary") != null ? Model.Item.GetList("ImageFilterSecondary").SelectedValue : "none"; 2711 string containerBackgroundImageFilterColorCode = Model.Item.GetString("ColorForTheFilter").StartsWith("#") && containerBackgroundImageFilterPrimary == "colorize" ? "style=\"background-color: " + GenerateRgba(Model.Item.GetString("ColorForTheFilter"), 0.3) + "\"" : ""; 2712 2713 if (containerBackgroundImageFilterPrimary == "colorize" && !containerBackgroundImageFilterPrimary.StartsWith("#")) 2714 { 2715 containerBackgroundImageFilterPrimary = containerBackgroundImageFilterColor; 2716 } 2717 2718 /* Custom */ 2719 if (Model.Item.GetFile("BackgroundImage") != null) 2720 { 2721 containerBackgroundImage = "/Admin/Public/GetImage.ashx?width=2500&amp;height=1100&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 2722 containerBackgroundImagePure = Model.Item.GetFile("BackgroundImage").Path; 2723 containerBackgroundImageLarge = "/Admin/Public/GetImage.ashx?width=1920&amp;height=845&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 2724 containerBackgroundImageMedium = "/Admin/Public/GetImage.ashx?width=1024&amp;height=450&amp;crop=0&amp;&amp;FillCanvas=TrueCompression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 2725 containerBackgroundImageSmall = "/Admin/Public/GetImage.ashx?width=640&amp;height=544&amp;crop=0&amp;&amp;FillCanvas=TrueCompression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 2726 2727 // Get metadata for file 2728 Dynamicweb.Content.Files.Metadata.Meta m = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(Dynamicweb.Context.Current.Server.MapPath(containerBackgroundImagePure)); 2729 2730 if (m != null) 2731 { 2732 var lang = PageView.Current().Area.CultureInfo.TwoLetterISOLanguageName; 2733 switch (lang) 2734 { 2735 case "da": 2736 containerBackgroundAltText = m.GetValue("alttext_dk"); 2737 break; 2738 case "de": 2739 containerBackgroundAltText = m.GetValue("alttext_de"); 2740 break; 2741 case "fr": 2742 containerBackgroundAltText = m.GetValue("alttext_fr"); 2743 break; 2744 default: 2745 containerBackgroundAltText = m.GetValue("alttext"); 2746 break; 2747 } 2748 } 2749 } 2750 else if (string.IsNullOrEmpty(backgroundColor)) 2751 { 2752 backgroundColor = "u-color-light--bg"; 2753 } 2754 2755 //Separation line 2756 bool hasSeparationLine = Model.Item.GetBoolean("SeperationLineAfter"); 2757 if (hasSeparationLine && Model.Item.GetList("Width").SelectedValue != "center") 2758 { 2759 paragraphContainerClasses += "multiple-paragraphs-container--seperation-line-after "; 2760 } 2761 else if (hasSeparationLine) 2762 { 2763 containerClasses += "multiple-paragraphs-container--seperation-line-after "; 2764 } 2765 2766 //Alternative Design Layout 2767 var designLayout = Model.Item.GetItem("CustomSettings") != null ? Model.Item.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.Item.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 2768 paragraphContainerClasses += !String.IsNullOrEmpty(designLayout) ? designLayout : ""; 2769 2770 var paragraphHeight = Model.Item.GetList("Height").SelectedValue; 2771 //Height 2772 if (!string.IsNullOrEmpty(paragraphHeight)) 2773 { 2774 gridClasses += "paragraph-container--height-" + paragraphHeight + " " + (paragraphHeight == "screen" ? "screen-height " : ""); 2775 } 2776 2777 if (Model.Item.GetString("MakeParagraphsCenterAligned") != null && Model.Item.GetBoolean("MakeParagraphsCenterAligned")) 2778 { 2779 gridClasses += "grid--justify-center "; 2780 } 2781 2782 //Set as carousel 2783 if (Model.Item.GetBoolean("EnableCarousel")) 2784 { 2785 containerClasses.Replace(" paragraph-container ", ""); 2786 } 2787 2788 //getting video ID from youtube URL 2789 string videoCode = Model.Item.GetString("VideoURL"); 2790 Regex regex = new Regex(@".be\/(.[^?]*)"); 2791 Match match = regex.Match(videoCode); 2792 string videoId = ""; 2793 if (match.Success) 2794 { 2795 videoId = match.Groups[1].Value; 2796 } 2797 else 2798 { 2799 regex = new Regex(@"v=([^&]+)"); 2800 match = regex.Match(videoCode); 2801 if (match.Success) 2802 { 2803 videoId = match.Groups[1].Value; 2804 } 2805 } 2806 } 2807 2808 <div class="grid__col-md-12 grid__col--bleed"> 2809 <section class="multiple-paragraphs-container @paragraphContainerClasses multiple-paragraphs-container--spacing-@spacingSize dw-mod" @colorSettings> 2810 <div class="background-image image-filter image-filter--@containerBackgroundImageFilterPrimary dw-mod" @containerBackgroundImageFilterColorCode> 2811 <div class="background-image__wrapper image-filter image-filter--@containerBackgroundImageFilterSecondary dw-mod"> 2812 @if (!String.IsNullOrEmpty(Model.Item.GetString("BackgroundImage"))) { 2813 @Render(new Image { 2814 Path = Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters, 2815 CssClass = "background-image__cover", 2816 DisableLazyLoad = false, 2817 Title = containerBackgroundAltText, 2818 ImageDefault = new ImageSettings { 2819 Width = 1920, 2820 Height = 845, 2821 Crop = 0, 2822 FillCanvas = true 2823 }, 2824 ImageMedium = new ImageSettings 2825 { 2826 Width = 1024, 2827 Height = 450, 2828 Crop = 0, 2829 FillCanvas = true 2830 }, 2831 ImageSmall = new ImageSettings 2832 { 2833 Width = 640, 2834 Height = 544, 2835 Crop = 0, 2836 FillCanvas = true 2837 } 2838 }) 2839 } 2840 2841 @if (!string.IsNullOrEmpty(videoId)) 2842 { 2843 <div class="video-background"> 2844 <div class="video-background__container"> 2845 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Model.ID)"></div> 2846 </div> 2847 </div> 2848 } 2849 </div> 2850 </div> 2851 2852 @if (!Model.Item.GetBoolean("EnableCarousel")) 2853 { 2854 <div class="@containerClasses dw-mod"> 2855 <div class="grid @gridClasses dw-mod"> 2856 @foreach (var paragraph in Model.Item.GetItems("Paragraph")) 2857 { 2858 @RenderParagraph(paragraph, false) 2859 } 2860 @if (!String.IsNullOrEmpty(Model.GetModuleOutput())) { 2861 <div class="paragraph-container grid__col-12 dw-mod"> 2862 @Render(new ContentModule { Content = Model.GetModuleOutput() }) 2863 </div> 2864 } 2865 </div> 2866 </div> 2867 } 2868 else 2869 { 2870 var slides = new List<List<Dynamicweb.Frontend.ItemViewModel>>(); 2871 int tempColumnsCount = 0; 2872 var paragraphs = Model.Item.GetItems("Paragraph"); 2873 bool hasAtLeastOneVisibleParagraph = false; 2874 if (paragraphs.Count > 0) 2875 { 2876 slides.Add(new List<Dynamicweb.Frontend.ItemViewModel>()); 2877 } 2878 2879 foreach (var paragraph in paragraphs) 2880 { 2881 int columnWidth = 0; 2882 if (Pageview.Device.ToString() == "Mobile" && paragraph.GetList("WidthMobile").SelectedValue == "hide") 2883 { 2884 continue; 2885 } 2886 hasAtLeastOneVisibleParagraph = true; 2887 if (paragraph.GetList("Width").SelectedValue != "auto") 2888 { 2889 columnWidth = Pageview.Device.ToString() != "Mobile" ? Int32.Parse(paragraph.GetList("Width").SelectedValue) : Int32.Parse(paragraph.GetList("WidthMobile").SelectedValue); 2890 } 2891 else 2892 { 2893 columnWidth = 1; 2894 } 2895 2896 if (tempColumnsCount + columnWidth > 12) 2897 { 2898 slides.Add(new List<Dynamicweb.Frontend.ItemViewModel>()); 2899 tempColumnsCount = 0; 2900 } 2901 2902 slides[slides.Count - 1].Add(paragraph); 2903 tempColumnsCount += columnWidth; 2904 } 2905 2906 if (hasAtLeastOneVisibleParagraph) 2907 { 2908 <div class="@containerClasses dw-mod"> 2909 <div class="carousel dw-mod" id="Paragraph_@(Model.ID)"> 2910 <div class="carousel__container js-carousel-slides dw-mod"> 2911 @foreach (var slide in slides) 2912 { 2913 <div class="carousel__slide dw-mod"> 2914 <div class="grid @gridClasses dw-mod"> 2915 @foreach (var paragraph in slide) 2916 { 2917 @RenderParagraph(paragraph, false) 2918 } 2919 </div> 2920 </div> 2921 } 2922 </div> 2923 </div> 2924 </div> 2925 } 2926 2927 if (slides.Count > 1) 2928 { 2929 bool enableDots = Model.Item.GetBoolean("ShowDots"); 2930 2931 <script> 2932 document.addEventListener("DOMContentLoaded", function () { 2933 new CarouselModule("#Paragraph_@(Model.ID)", { 2934 slideTime: @Model.Item.GetString("SlideTime"), 2935 dots: @(Model.Item.GetBoolean("ShowDots").ToString().ToLower()) 2936 }); 2937 }) 2938 </script> 2939 } 2940 } 2941 </section> 2942 </div> 2943
Error executing template "Designs/Rapido/Paragraph/ParagraphContainer.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_71523f4092f34a81aceab22071a7b773.Execute() in D:\dynamicweb.net\Solutions\Production\Files\Templates\Designs\Rapido\Paragraph\ParagraphContainer.cshtml:line 2813
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.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 if (settings.DisableImageEngine) 741 { 742 defaultImage = settings.Path; 743 } 744 else 745 { 746 if (settings.ImageDefault != null) 747 { 748 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 749 750 if (settings.Path.GetType() != typeof(string)) 751 { 752 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 753 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 754 } 755 else 756 { 757 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 758 } 759 760 defaultImage += "&AlternativeImage=" + alternativeImage; 761 } 762 763 if (settings.ImageSmall != null) 764 { 765 imageSmall = "data-src-small=\"" + imageEngine; 766 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 767 768 if (settings.Path.GetType() != typeof(string)) 769 { 770 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 771 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 772 } 773 else 774 { 775 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 776 } 777 778 imageSmall += "&alternativeImage=" + alternativeImage; 779 780 imageSmall += "\""; 781 } 782 783 if (settings.ImageMedium != null) 784 { 785 imageMedium = "data-src-medium=\"" + imageEngine; 786 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 787 788 if (settings.Path.GetType() != typeof(string)) 789 { 790 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 791 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 792 } 793 else 794 { 795 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 796 } 797 798 imageMedium += "&alternativeImage=" + alternativeImage; 799 800 imageMedium += "\""; 801 } 802 } 803 804 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 805 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 806 if (!string.IsNullOrEmpty(settings.Title)) 807 { 808 optionalAttributes.Add("alt", settings.Title); 809 optionalAttributes.Add("title", settings.Title); 810 } 811 812 if (settings.DisableLazyLoad) 813 { 814 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 815 } 816 else 817 { 818 <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) /> 819 } 820 } 821 } 822 @using System.Reflection 823 @using Dynamicweb.Rapido.Blocks.Components.General 824 @using Dynamicweb.Rapido.Blocks.Components 825 826 @* Component *@ 827 828 @helper RenderFileField(FileField settings) 829 { 830 var attributes = new Dictionary<string, string>(); 831 if (string.IsNullOrEmpty(settings.Id)) 832 { 833 settings.Id = Guid.NewGuid().ToString("N"); 834 } 835 836 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 837 if (settings.Disabled) { attributes.Add("disabled", "true"); } 838 if (settings.Required) { attributes.Add("required", "true"); } 839 if (settings.Multiple) { attributes.Add("multiple", "true"); } 840 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 841 if (string.IsNullOrEmpty(settings.ChooseFileText)) 842 { 843 settings.ChooseFileText = Translate("Choose file"); 844 } 845 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 846 { 847 settings.NoFilesChosenText = Translate("No files chosen..."); 848 } 849 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 850 851 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 852 853 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 854 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 855 856 attributes.Add("type", "file"); 857 if (settings.Value != null) { attributes.Add("value", settings.Value); } 858 settings.CssClass = "u-full-width " + settings.CssClass; 859 860 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 861 862 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 863 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 864 { 865 <div class="u-full-width"> 866 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 867 @if (settings.Link != null) { 868 <div class="u-pull--right"> 869 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 870 @Render(settings.Link) 871 </div> 872 } 873 </div> 874 875 } 876 877 @if (!string.IsNullOrEmpty(settings.HelpText)) 878 { 879 <small class="form__help-text">@settings.HelpText</small> 880 } 881 882 <div class="form__field-combi file-input u-no-margin dw-mod"> 883 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 884 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 885 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 886 @if (settings.UploadButton != null) 887 { 888 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 889 @Render(settings.UploadButton) 890 } 891 </div> 892 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 893 </div> 894 } 895 @using System.Reflection 896 @using Dynamicweb.Rapido.Blocks.Components.General 897 @using Dynamicweb.Rapido.Blocks.Components 898 @using Dynamicweb.Core 899 @using System.Linq 900 901 @* Component *@ 902 903 @helper RenderDateTimeField(DateTimeField settings) 904 { 905 if (string.IsNullOrEmpty(settings.Id)) 906 { 907 settings.Id = Guid.NewGuid().ToString("N"); 908 } 909 910 var textField = new TextField { 911 Name = settings.Name, 912 Id = settings.Id, 913 Label = settings.Label, 914 HelpText = settings.HelpText, 915 Value = settings.Value, 916 Disabled = settings.Disabled, 917 Required = settings.Required, 918 ErrorMessage = settings.ErrorMessage, 919 CssClass = settings.CssClass, 920 WrapperCssClass = settings.WrapperCssClass, 921 OnChange = settings.OnChange, 922 OnClick = settings.OnClick, 923 Link = settings.Link, 924 ExtraAttributes = settings.ExtraAttributes, 925 // 926 Placeholder = settings.Placeholder 927 }; 928 929 @Render(textField) 930 931 List<string> jsAttributes = new List<string>(); 932 933 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 934 935 if (!string.IsNullOrEmpty(settings.DateFormat)) 936 { 937 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 938 } 939 if (!string.IsNullOrEmpty(settings.MinDate)) 940 { 941 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 942 } 943 if (!string.IsNullOrEmpty(settings.MaxDate)) 944 { 945 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 946 } 947 if (settings.IsInline) 948 { 949 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 950 } 951 if (settings.EnableTime) 952 { 953 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 954 } 955 if (settings.EnableWeekNumbers) 956 { 957 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 958 } 959 960 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 961 962 <script> 963 document.addEventListener("DOMContentLoaded", function () { 964 flatpickr("#@textField.Id", { 965 @string.Join(",", jsAttributes) 966 }); 967 }); 968 </script> 969 } 970 @using System.Reflection 971 @using Dynamicweb.Rapido.Blocks.Components.General 972 @using Dynamicweb.Rapido.Blocks.Components 973 974 @* Component *@ 975 976 @helper RenderTextField(TextField settings) 977 { 978 var attributes = new Dictionary<string, string>(); 979 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 980 { 981 settings.Id = Guid.NewGuid().ToString("N"); 982 } 983 984 /*base settings*/ 985 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 986 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 987 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 988 if (settings.Disabled) { attributes.Add("disabled", "true"); } 989 if (settings.Required) { attributes.Add("required", "true"); } 990 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 991 /*end*/ 992 993 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 994 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 995 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 996 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 997 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 998 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 999 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1000 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1001 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1002 1003 settings.CssClass = "u-full-width " + settings.CssClass; 1004 1005 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1006 1007 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1008 1009 string noMargin = "u-no-margin"; 1010 if (!settings.ReadOnly) { 1011 noMargin = ""; 1012 } 1013 1014 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1015 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1016 { 1017 <div class="u-full-width"> 1018 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1019 @if (settings.Link != null) { 1020 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1021 1022 <div class="u-pull--right"> 1023 @Render(settings.Link) 1024 </div> 1025 } 1026 </div> 1027 1028 } 1029 1030 @if (!string.IsNullOrEmpty(settings.HelpText)) 1031 { 1032 <small class="form__help-text">@settings.HelpText</small> 1033 } 1034 1035 @if (settings.ActionButton != null) 1036 { 1037 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1038 <div class="form__field-combi u-no-margin dw-mod"> 1039 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1040 @Render(settings.ActionButton) 1041 </div> 1042 } 1043 else 1044 { 1045 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1046 } 1047 1048 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1049 </div> 1050 } 1051 @using System.Reflection 1052 @using Dynamicweb.Rapido.Blocks.Components.General 1053 @using Dynamicweb.Rapido.Blocks.Components 1054 1055 @* Component *@ 1056 1057 @helper RenderNumberField(NumberField settings) 1058 { 1059 var attributes = new Dictionary<string, string>(); 1060 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1061 { 1062 settings.Id = Guid.NewGuid().ToString("N"); 1063 } 1064 1065 /*base settings*/ 1066 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1067 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1068 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1069 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1070 if (settings.Required) { attributes.Add("required", "true"); } 1071 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1072 /*end*/ 1073 1074 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1075 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1076 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1077 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1078 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1079 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1080 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1081 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1082 attributes.Add("type", "number"); 1083 1084 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1085 1086 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1087 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1088 { 1089 <div class="u-full-width"> 1090 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1091 @if (settings.Link != null) { 1092 <div class="u-pull--right"> 1093 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1094 @Render(settings.Link) 1095 </div> 1096 } 1097 </div> 1098 1099 } 1100 1101 @if (!string.IsNullOrEmpty(settings.HelpText)) 1102 { 1103 <small class="form__help-text">@settings.HelpText</small> 1104 } 1105 1106 @if (settings.ActionButton != null) 1107 { 1108 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1109 <div class="form__field-combi u-no-margin dw-mod"> 1110 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1111 @Render(settings.ActionButton) 1112 </div> 1113 } 1114 else 1115 { 1116 <div class="form__field-combi u-no-margin dw-mod"> 1117 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1118 </div> 1119 } 1120 1121 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1122 </div> 1123 } 1124 @using System.Reflection 1125 @using Dynamicweb.Rapido.Blocks.Components.General 1126 @using Dynamicweb.Rapido.Blocks.Components 1127 1128 1129 @* Component *@ 1130 1131 @helper RenderTextareaField(TextareaField settings) 1132 { 1133 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1134 string id = settings.Id; 1135 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1136 { 1137 id = Guid.NewGuid().ToString("N"); 1138 } 1139 1140 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1141 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1142 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1143 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1144 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1145 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1146 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1147 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1148 if (settings.Required) { attributes.Add("required", "true"); } 1149 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1150 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1151 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1152 attributes.Add("name", settings.Name); 1153 1154 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1155 1156 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1157 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1158 { 1159 <div class="u-full-width"> 1160 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1161 @if (settings.Link != null) { 1162 <div class="u-pull--right"> 1163 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1164 @Render(settings.Link) 1165 </div> 1166 } 1167 </div> 1168 } 1169 1170 @if (!string.IsNullOrEmpty(settings.HelpText)) 1171 { 1172 <small class="form__help-text">@settings.HelpText</small> 1173 } 1174 1175 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1176 1177 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1178 </div> 1179 } 1180 @using System.Reflection 1181 @using Dynamicweb.Rapido.Blocks.Components.General 1182 @using Dynamicweb.Rapido.Blocks.Components 1183 1184 1185 @* Component *@ 1186 1187 @helper RenderHiddenField(HiddenField settings) { 1188 var attributes = new Dictionary<string, string>(); 1189 attributes.Add("type", "hidden"); 1190 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1191 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1192 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1193 1194 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1195 } 1196 @using System.Reflection 1197 @using Dynamicweb.Rapido.Blocks.Components.General 1198 @using Dynamicweb.Rapido.Blocks.Components 1199 1200 @* Component *@ 1201 1202 @helper RenderCheckboxField(CheckboxField settings) 1203 { 1204 var attributes = new Dictionary<string, string>(); 1205 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1206 { 1207 settings.Id = Guid.NewGuid().ToString("N"); 1208 } 1209 1210 /*base settings*/ 1211 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1212 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1213 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1214 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1215 if (settings.Required) { attributes.Add("required", "true"); } 1216 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1217 /*end*/ 1218 1219 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1220 1221 attributes.Add("type", "checkbox"); 1222 if (settings.Checked) { attributes.Add("checked", "true"); } 1223 settings.CssClass = "form__control " + settings.CssClass; 1224 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1225 1226 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1227 1228 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1229 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1230 @if (!string.IsNullOrEmpty(settings.Label)) 1231 { 1232 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1233 } 1234 1235 @if (settings.Link != null) { 1236 <span> 1237 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1238 @Render(settings.Link) 1239 </span> 1240 } 1241 1242 @if (!string.IsNullOrEmpty(settings.HelpText)) 1243 { 1244 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1245 } 1246 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1247 </div> 1248 } 1249 @using System.Reflection 1250 @using Dynamicweb.Rapido.Blocks.Components.General 1251 @using Dynamicweb.Rapido.Blocks.Components 1252 1253 1254 @* Component *@ 1255 1256 @helper RenderCheckboxListField(CheckboxListField settings) 1257 { 1258 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1259 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1260 { 1261 <div class="u-full-width"> 1262 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1263 @if (settings.Link != null) { 1264 <div class="u-pull--right"> 1265 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1266 @Render(settings.Link) 1267 </div> 1268 } 1269 </div> 1270 1271 } 1272 1273 <div class="u-pull--left"> 1274 @if (!string.IsNullOrEmpty(settings.HelpText)) 1275 { 1276 <small class="form__help-text">@settings.HelpText</small> 1277 } 1278 1279 @foreach (var item in settings.Options) 1280 { 1281 if (settings.Required) 1282 { 1283 item.Required = true; 1284 } 1285 if (settings.Disabled) 1286 { 1287 item.Disabled = true; 1288 } 1289 if (!string.IsNullOrEmpty(settings.Name)) 1290 { 1291 item.Name = settings.Name; 1292 } 1293 if (!string.IsNullOrEmpty(settings.CssClass)) 1294 { 1295 item.CssClass += settings.CssClass; 1296 } 1297 1298 /* value is not supported */ 1299 1300 if (!string.IsNullOrEmpty(settings.OnClick)) 1301 { 1302 item.OnClick += settings.OnClick; 1303 } 1304 if (!string.IsNullOrEmpty(settings.OnChange)) 1305 { 1306 item.OnChange += settings.OnChange; 1307 } 1308 @Render(item) 1309 } 1310 1311 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1312 </div> 1313 1314 </div> 1315 } 1316 @using Dynamicweb.Rapido.Blocks.Components.General 1317 1318 @* Component *@ 1319 1320 @helper RenderSearch(Search settings) 1321 { 1322 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1323 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1324 1325 if (string.IsNullOrEmpty(settings.Id)) 1326 { 1327 settings.Id = Guid.NewGuid().ToString("N"); 1328 } 1329 1330 var resultAttributes = new Dictionary<string, string>(); 1331 1332 if (settings.PageSize != 0) 1333 { 1334 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1335 } 1336 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1337 { 1338 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1339 if (!string.IsNullOrEmpty(groupValue)) 1340 { 1341 resultAttributes.Add("data-selected-group", groupValue); 1342 } 1343 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1344 { 1345 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1346 } 1347 } 1348 resultAttributes.Add("data-force-init", "true"); 1349 if (settings.GoToFirstSearchResultOnEnter) 1350 { 1351 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1352 } 1353 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1354 { 1355 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1356 } 1357 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1358 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1359 1360 if (settings.SecondSearchData != null) 1361 { 1362 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1363 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1364 } 1365 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1366 { 1367 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1368 } 1369 1370 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1371 1372 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1373 1374 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1375 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1376 { 1377 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1378 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1379 } 1380 1381 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1382 1383 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1384 @if (settings.SecondSearchData != null) 1385 { 1386 <div class="search__column search__column--products dw-mod"> 1387 <div class="search__column-header dw-mod">@Translate("Products")</div> 1388 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1389 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1390 { 1391 @Render(new Link { 1392 Title = Translate("View all"), 1393 CssClass = "js-view-all-button u-margin", 1394 Href = settings.SearchData.ResultsPageUrl 1395 }); 1396 } 1397 </div> 1398 <div class="search__column search__column--pages dw-mod"> 1399 <div class="search__column-header">@Translate("Pages")</div> 1400 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1401 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1402 { 1403 @Render(new Link 1404 { 1405 Title = Translate("View all"), 1406 CssClass = "js-view-all-button u-margin", 1407 Href = settings.SecondSearchData.ResultsPageUrl 1408 }); 1409 } 1410 </div> 1411 } 1412 else 1413 { 1414 <div class="search__column search__column--only dw-mod"> 1415 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1416 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1417 { 1418 @Render(new Link { 1419 Title = Translate("View all"), 1420 CssClass = "js-view-all-button u-margin", 1421 Href = settings.SearchData.ResultsPageUrl 1422 }); 1423 } 1424 </div> 1425 } 1426 </div> 1427 1428 @if (settings.SearchButton != null) 1429 { 1430 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1431 if (settings.RenderDefaultSearchIcon) 1432 { 1433 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1434 } 1435 @Render(settings.SearchButton); 1436 } 1437 </div> 1438 } 1439 @using System.Reflection 1440 @using Dynamicweb.Rapido.Blocks.Components.General 1441 @using Dynamicweb.Rapido.Blocks.Components 1442 1443 1444 @* Component *@ 1445 1446 @helper RenderSelectField(SelectField settings) 1447 { 1448 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1449 { 1450 settings.Id = Guid.NewGuid().ToString("N"); 1451 } 1452 1453 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1454 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1455 { 1456 <div class="u-full-width"> 1457 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1458 @if (settings.Link != null) { 1459 <div class="u-pull--right"> 1460 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1461 @Render(settings.Link) 1462 </div> 1463 } 1464 </div> 1465 } 1466 1467 @if (!string.IsNullOrEmpty(settings.HelpText)) 1468 { 1469 <small class="form__help-text">@settings.HelpText</small> 1470 } 1471 1472 @if (settings.ActionButton != null) 1473 { 1474 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1475 <div class="form__field-combi u-no-margin dw-mod"> 1476 @RenderSelectBase(settings) 1477 @Render(settings.ActionButton) 1478 </div> 1479 } 1480 else 1481 { 1482 @RenderSelectBase(settings) 1483 } 1484 1485 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1486 </div> 1487 } 1488 1489 @helper RenderSelectBase(SelectField settings) 1490 { 1491 var attributes = new Dictionary<string, string>(); 1492 1493 /*base settings*/ 1494 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1495 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1496 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1497 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1498 if (settings.Required) { attributes.Add("required", "true"); } 1499 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1500 /*end*/ 1501 1502 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1503 1504 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1505 @if (settings.Default != null) 1506 { 1507 @Render(settings.Default) 1508 } 1509 1510 @foreach (var item in settings.Options) 1511 { 1512 if (settings.Value != null) { 1513 item.Checked = item.Value == settings.Value; 1514 } 1515 @Render(item) 1516 } 1517 </select> 1518 } 1519 @using System.Reflection 1520 @using Dynamicweb.Rapido.Blocks.Components.General 1521 @using Dynamicweb.Rapido.Blocks.Components 1522 1523 @* Component *@ 1524 1525 @helper RenderRadioButtonField(RadioButtonField settings) 1526 { 1527 var attributes = new Dictionary<string, string>(); 1528 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1529 { 1530 settings.Id = Guid.NewGuid().ToString("N"); 1531 } 1532 1533 /*base settings*/ 1534 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1535 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1536 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1537 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1538 if (settings.Required) { attributes.Add("required", "true"); } 1539 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1540 /*end*/ 1541 1542 attributes.Add("type", "radio"); 1543 if (settings.Checked) { attributes.Add("checked", "true"); } 1544 settings.CssClass = "form__control " + settings.CssClass; 1545 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1546 1547 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1548 1549 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1550 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1551 @if (!string.IsNullOrEmpty(settings.Label)) 1552 { 1553 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1554 } 1555 @if (!string.IsNullOrEmpty(settings.HelpText)) 1556 { 1557 <small class="form__help-text">@settings.HelpText</small> 1558 } 1559 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1560 </div> 1561 } 1562 @using System.Reflection 1563 @using Dynamicweb.Rapido.Blocks.Components.General 1564 @using Dynamicweb.Rapido.Blocks.Components 1565 1566 1567 @* Component *@ 1568 1569 @helper RenderRadioButtonListField(RadioButtonListField settings) 1570 { 1571 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1572 1573 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1574 @if (!string.IsNullOrEmpty(settings.Label)) 1575 { 1576 <label>@settings.Label</label> 1577 } 1578 @if (!string.IsNullOrEmpty(settings.HelpText)) 1579 { 1580 <small class="form__help-text">@settings.HelpText</small> 1581 } 1582 1583 @foreach (var item in settings.Options) 1584 { 1585 if (settings.Required) 1586 { 1587 item.Required = true; 1588 } 1589 if (settings.Disabled) 1590 { 1591 item.Disabled = true; 1592 } 1593 if (!string.IsNullOrEmpty(settings.Name)) 1594 { 1595 item.Name = settings.Name; 1596 } 1597 if (settings.Value != null && settings.Value == item.Value) 1598 { 1599 item.Checked = true; 1600 } 1601 if (!string.IsNullOrEmpty(settings.OnClick)) 1602 { 1603 item.OnClick += settings.OnClick; 1604 } 1605 if (!string.IsNullOrEmpty(settings.OnChange)) 1606 { 1607 item.OnChange += settings.OnChange; 1608 } 1609 if (!string.IsNullOrEmpty(settings.CssClass)) 1610 { 1611 item.CssClass += settings.CssClass; 1612 } 1613 @Render(item) 1614 } 1615 1616 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1617 </div> 1618 } 1619 @using System.Reflection 1620 @using Dynamicweb.Rapido.Blocks.Components.General 1621 @using Dynamicweb.Rapido.Blocks.Components 1622 1623 1624 @* Component *@ 1625 1626 @helper RenderNotificationMessage(NotificationMessage settings) 1627 { 1628 if (!string.IsNullOrEmpty(settings.Message)) 1629 { 1630 var attributes = new Dictionary<string, string>(); 1631 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1632 1633 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1634 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1635 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1636 1637 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1638 @if (settings.Icon != null) { 1639 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1640 @Render(settings.Icon) 1641 } else { 1642 @settings.Message 1643 } 1644 </div> 1645 } 1646 } 1647 @using Dynamicweb.Rapido.Blocks.Components.General 1648 1649 1650 @* Component *@ 1651 1652 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1653 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1654 1655 <div class="@settings.CssClass dw-mod js-handlebars-root" id="@settings.Id" data-template="@settings.ScriptTemplate" data-json-feed="@settings.FeedUrl" data-init-onload="@settings.InitOnLoad.ToString()" data-preloader="@settings.Preloader" @preRender> 1656 @if (settings.SubBlocks != null) { 1657 @RenderBlockList(settings.SubBlocks) 1658 } 1659 </div> 1660 } 1661 @using System.Reflection 1662 @using Dynamicweb.Rapido.Blocks.Components.General 1663 @using Dynamicweb.Rapido.Blocks.Components 1664 @using System.Text.RegularExpressions 1665 1666 1667 @* Component *@ 1668 1669 @helper RenderSticker(Sticker settings) { 1670 if (!String.IsNullOrEmpty(settings.Title)) { 1671 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1672 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1673 1674 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1675 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1676 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1677 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1678 optionalAttributes.Add("style", styleTag); 1679 } 1680 1681 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1682 } 1683 } 1684 1685 @using System.Reflection 1686 @using Dynamicweb.Rapido.Blocks.Components.General 1687 @using Dynamicweb.Rapido.Blocks.Components 1688 1689 1690 @* Component *@ 1691 1692 @helper RenderStickersCollection(StickersCollection settings) 1693 { 1694 if (settings.Stickers.Count > 0) 1695 { 1696 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1697 1698 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1699 @foreach (Sticker sticker in settings.Stickers) 1700 { 1701 @Render(sticker) 1702 } 1703 </div> 1704 } 1705 } 1706 1707 @using Dynamicweb.Rapido.Blocks.Components.General 1708 1709 1710 @* Component *@ 1711 1712 @helper RenderForm(Form settings) { 1713 if (settings != null) 1714 { 1715 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1716 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1717 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1718 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1719 var enctypes = new Dictionary<string, string> 1720 { 1721 { "multipart", "multipart/form-data" }, 1722 { "text", "text/plain" }, 1723 { "application", "application/x-www-form-urlencoded" } 1724 }; 1725 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1726 optionalAttributes.Add("method", settings.Method.ToString()); 1727 1728 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1729 { 1730 @settings.FormStartMarkup 1731 } 1732 else 1733 { 1734 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1735 } 1736 1737 foreach (var field in settings.GetFields()) 1738 { 1739 @Render(field) 1740 } 1741 1742 @:</form> 1743 } 1744 } 1745 @using System.Reflection 1746 @using Dynamicweb.Rapido.Blocks.Components.General 1747 @using Dynamicweb.Rapido.Blocks.Components 1748 1749 1750 @* Component *@ 1751 1752 @helper RenderText(Text settings) 1753 { 1754 @settings.Content 1755 } 1756 @using System.Reflection 1757 @using Dynamicweb.Rapido.Blocks.Components.General 1758 @using Dynamicweb.Rapido.Blocks.Components 1759 1760 1761 @* Component *@ 1762 1763 @helper RenderContentModule(ContentModule settings) { 1764 if (!string.IsNullOrEmpty(settings.Content)) 1765 { 1766 @settings.Content 1767 } 1768 } 1769 @using System.Reflection 1770 @using Dynamicweb.Rapido.Blocks.Components.General 1771 @using Dynamicweb.Rapido.Blocks.Components 1772 1773 1774 @* Component *@ 1775 1776 @helper RenderModal(Modal settings) { 1777 if (settings != null) 1778 { 1779 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1780 1781 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1782 1783 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1784 1785 <div class="modal-container"> 1786 @if (!settings.DisableDarkOverlay) 1787 { 1788 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1789 } 1790 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1791 @if (settings.Heading != null) 1792 { 1793 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1794 { 1795 <div class="modal__header"> 1796 @Render(settings.Heading) 1797 </div> 1798 } 1799 } 1800 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1801 @if (!string.IsNullOrEmpty(settings.BodyText)) 1802 { 1803 @settings.BodyText 1804 } 1805 @if (settings.BodyTemplate != null) 1806 { 1807 @settings.BodyTemplate 1808 } 1809 @{ 1810 var actions = settings.GetActions(); 1811 } 1812 </div> 1813 @if (actions.Length > 0) 1814 { 1815 <div class="modal__footer"> 1816 @foreach (var action in actions) 1817 { 1818 if (Pageview.Device.ToString() != "Mobile") { 1819 action.CssClass += " u-no-margin"; 1820 } else { 1821 action.CssClass += " u-full-width u-margin-bottom"; 1822 } 1823 1824 @Render(action) 1825 } 1826 </div> 1827 } 1828 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1829 </div> 1830 </div> 1831 } 1832 } 1833 @using Dynamicweb.Rapido.Blocks.Components.General 1834 1835 @* Component *@ 1836 1837 @helper RenderMediaListItem(MediaListItem settings) 1838 { 1839 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1840 @if (!string.IsNullOrEmpty(settings.Label)) 1841 { 1842 if (!string.IsNullOrEmpty(settings.Link)) 1843 { 1844 @Render(new Link 1845 { 1846 Href = settings.Link, 1847 CssClass = "media-list-item__sticker dw-mod", 1848 ButtonLayout = ButtonLayout.None, 1849 Title = settings.Label, 1850 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1851 }) 1852 } 1853 else if (!string.IsNullOrEmpty(settings.OnClick)) 1854 { 1855 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1856 <span class="u-uppercase">@settings.Label</span> 1857 </span> 1858 } 1859 else 1860 { 1861 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1862 <span class="u-uppercase">@settings.Label</span> 1863 </span> 1864 } 1865 } 1866 <div class="media-list-item__wrap"> 1867 <div class="media-list-item__info dw-mod"> 1868 <div class="media-list-item__header dw-mod"> 1869 @if (!string.IsNullOrEmpty(settings.Title)) 1870 { 1871 if (!string.IsNullOrEmpty(settings.Link)) 1872 { 1873 @Render(new Link 1874 { 1875 Href = settings.Link, 1876 CssClass = "media-list-item__name dw-mod", 1877 ButtonLayout = ButtonLayout.None, 1878 Title = settings.Title, 1879 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1880 }) 1881 } 1882 else if (!string.IsNullOrEmpty(settings.OnClick)) 1883 { 1884 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1885 } 1886 else 1887 { 1888 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1889 } 1890 } 1891 1892 @if (!string.IsNullOrEmpty(settings.Status)) 1893 { 1894 <div class="media-list-item__state dw-mod">@settings.Status</div> 1895 } 1896 </div> 1897 @{ 1898 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1899 } 1900 1901 @Render(settings.InfoTable) 1902 </div> 1903 <div class="media-list-item__actions dw-mod"> 1904 <div class="media-list-item__actions-list dw-mod"> 1905 @{ 1906 var actions = settings.GetActions(); 1907 1908 foreach (ButtonBase action in actions) 1909 { 1910 action.ButtonLayout = ButtonLayout.None; 1911 action.CssClass += " media-list-item__action link"; 1912 1913 @Render(action) 1914 } 1915 } 1916 </div> 1917 1918 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1919 { 1920 settings.SelectButton.CssClass += " u-no-margin"; 1921 1922 <div class="media-list-item__action-button"> 1923 @Render(settings.SelectButton) 1924 </div> 1925 } 1926 </div> 1927 </div> 1928 </div> 1929 } 1930 @using Dynamicweb.Rapido.Blocks.Components.General 1931 @using Dynamicweb.Rapido.Blocks.Components 1932 1933 @helper RenderTable(Table settings) 1934 { 1935 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1936 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1937 1938 var enumToClasses = new Dictionary<TableDesign, string> 1939 { 1940 { TableDesign.Clean, "table--clean" }, 1941 { TableDesign.Bordered, "table--bordered" }, 1942 { TableDesign.Striped, "table--striped" }, 1943 { TableDesign.Hover, "table--hover" }, 1944 { TableDesign.Compact, "table--compact" }, 1945 { TableDesign.Condensed, "table--condensed" }, 1946 { TableDesign.NoTopBorder, "table--no-top-border" } 1947 }; 1948 string tableDesignClass = ""; 1949 if (settings.Design != TableDesign.None) 1950 { 1951 tableDesignClass = enumToClasses[settings.Design]; 1952 } 1953 1954 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1955 1956 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1957 1958 <table @ComponentMethods.AddAttributes(resultAttributes)> 1959 @if (settings.Header != null) 1960 { 1961 <thead> 1962 @Render(settings.Header) 1963 </thead> 1964 } 1965 <tbody> 1966 @foreach (var row in settings.Rows) 1967 { 1968 @Render(row) 1969 } 1970 </tbody> 1971 @if (settings.Footer != null) 1972 { 1973 <tfoot> 1974 @Render(settings.Footer) 1975 </tfoot> 1976 } 1977 </table> 1978 } 1979 @using Dynamicweb.Rapido.Blocks.Components.General 1980 @using Dynamicweb.Rapido.Blocks.Components 1981 1982 @helper RenderTableRow(TableRow settings) 1983 { 1984 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1985 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1986 1987 var enumToClasses = new Dictionary<TableRowDesign, string> 1988 { 1989 { TableRowDesign.NoBorder, "table__row--no-border" }, 1990 { TableRowDesign.Border, "table__row--border" }, 1991 { TableRowDesign.TopBorder, "table__row--top-line" }, 1992 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1993 { TableRowDesign.Solid, "table__row--solid" } 1994 }; 1995 1996 string tableRowDesignClass = ""; 1997 if (settings.Design != TableRowDesign.None) 1998 { 1999 tableRowDesignClass = enumToClasses[settings.Design]; 2000 } 2001 2002 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2003 2004 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2005 2006 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2007 @foreach (var cell in settings.Cells) 2008 { 2009 if (settings.IsHeaderRow) 2010 { 2011 cell.IsHeader = true; 2012 } 2013 @Render(cell) 2014 } 2015 </tr> 2016 } 2017 @using Dynamicweb.Rapido.Blocks.Components.General 2018 @using Dynamicweb.Rapido.Blocks.Components 2019 @using Dynamicweb.Core 2020 2021 @helper RenderTableCell(TableCell settings) 2022 { 2023 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2024 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2025 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2026 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2027 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2028 2029 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2030 2031 string tagName = settings.IsHeader ? "th" : "td"; 2032 2033 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2034 @settings.Content 2035 @("</" + tagName + ">"); 2036 } 2037 @using System.Linq 2038 @using Dynamicweb.Rapido.Blocks.Components.General 2039 2040 @* Component *@ 2041 2042 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2043 { 2044 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2045 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2046 2047 if (settings.NumberOfPages > 1) 2048 { 2049 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2050 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2051 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2052 2053 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2054 @if (settings.ShowPagingInfo) 2055 { 2056 <div class="pager__info dw-mod"> 2057 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2058 </div> 2059 } 2060 <ul class="pager__list dw-mod"> 2061 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2062 { 2063 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2064 } 2065 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2066 { 2067 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2068 } 2069 @if (settings.GetPages().Any()) 2070 { 2071 foreach (var page in settings.GetPages()) 2072 { 2073 @Render(page) 2074 } 2075 } 2076 else 2077 { 2078 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2079 { 2080 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2081 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2082 } 2083 } 2084 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2085 { 2086 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2087 } 2088 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2089 { 2090 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2091 } 2092 </ul> 2093 </div> 2094 } 2095 } 2096 2097 @helper RenderPaginationItem(PaginationItem settings) 2098 { 2099 if (settings.Icon == null) 2100 { 2101 settings.Icon = new Icon(); 2102 } 2103 2104 settings.Icon.Label = settings.Label; 2105 <li class="pager__btn dw-mod"> 2106 @if (settings.IsActive) 2107 { 2108 <span class="pager__num pager__num--current dw-mod"> 2109 @Render(settings.Icon) 2110 </span> 2111 } 2112 else 2113 { 2114 <a href="@settings.Link" class="pager__num dw-mod"> 2115 @Render(settings.Icon) 2116 </a> 2117 } 2118 </li> 2119 } 2120 2121 2122 @using Dynamicweb.Rapido.Blocks.Components.General 2123 2124 @using Ppdw.Common; 2125 2126 @functions { 2127 public string PerfionImagePrefix(int width, int height) 2128 { 2129 return string.Format("{0}/Perfion/Image.aspx?size={1}x{2}&format=png&id=", GlobalSettingsHelper.GetValue(PicoGlobalSettingsNames.PerfionWebApiUrl), width, height); 2130 } 2131 } 2132 @using System.Xml.Linq; 2133 @using Ppdw.Common; 2134 @using System.Diagnostics; 2135 @using System.Text; 2136 @using Dynamicweb.Configuration; 2137 2138 @functions { 2139 2140 } 2141 2142 @helper RenderCraneArmIllustrationCollection(IEnumerable<int> perfionIds) 2143 { 2144 if (0 < perfionIds.Count()) 2145 { 2146 2147 2148 //var variantString = Convert.ToBase64String(Encoding.UTF8.GetBytes("[" + string.Join(",", variantJsObjects) + "]")); 2149 <canvas id="illustration-canvas" 2150 data-variants='@string.Join(",", perfionIds)' 2151 style="opacity: 0;width: 50%; height: 50%" 2152 @*data-scaling="@scaling" 2153 width="@(widestBase + widestJointSum + (mostJoints * (5 /* joint gap */ * scaling)) + (40 /* fly-jib indentation */ * scaling) + 10 /* image margin*/)" 2154 height="@(variantJsObjects.Count() * (120 * scaling))"*@ 2155 ></canvas> 2156 2157 <img id="illustration-img" style="width:50%;height:50%;" /> 2158 } 2159 } 2160 @using Ppdw.Common; 2161 2162 @functions { 2163 public string PerfionFilePrefix(Guid id) 2164 { 2165 return string.Format("{0}/Perfion/File.aspx?id={1}", GlobalSettingsHelper.GetValue(PicoGlobalSettingsNames.PerfionWebApiUrl), id); 2166 } 2167 } 2168 @using Dynamicweb.Rapido.Blocks.Components 2169 @using Dynamicweb.Rapido.Blocks.Components.General 2170 @using Dynamicweb.Rapido.Blocks 2171 2172 2173 @* Custom Component 2174 2175 * Added u-reset-position to secondary filter * 2176 *@ 2177 2178 @helper RenderImageCustom(Image settings) 2179 { 2180 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 2181 { 2182 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 2183 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 2184 2185 if (settings.Caption != null) 2186 { 2187 @:<div> 2188 } 2189 2190 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 2191 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 2192 2193 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 2194 <div class="image-filter image-filter--@secondaryFilterClass u-reset-position dw-mod"> 2195 @if (settings.Link != null) 2196 { 2197 <a href="@settings.Link"> 2198 @RenderTheImage(settings) 2199 </a> 2200 } 2201 else 2202 { 2203 @RenderTheImage(settings) 2204 } 2205 </div> 2206 </div> 2207 2208 if (settings.Caption != null) 2209 { 2210 <span class="image-caption dw-mod">@settings.Caption</span> 2211 @:</div> 2212 } 2213 } 2214 else 2215 { 2216 if (settings.Caption != null) 2217 { 2218 @:<div> 2219 } 2220 if (!string.IsNullOrEmpty(settings.Link)) 2221 { 2222 <a href="@settings.Link"> 2223 @RenderTheImage(settings) 2224 </a> 2225 } 2226 else 2227 { 2228 @RenderTheImage(settings) 2229 } 2230 2231 if (settings.Caption != null) 2232 { 2233 <span class="image-caption dw-mod">@settings.Caption</span> 2234 @:</div> 2235 } 2236 } 2237 } 2238 2239 2240 @* Include the basic, re-used, paragraph initializer *@ 2241 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2242 @using Dynamicweb.Frontend 2243 @using Dynamicweb.Rapido.Blocks.Components.General 2244 @using Dynamicweb.Rapido.Blocks.Components 2245 2246 @functions { 2247 public class ContentParagraph 2248 { 2249 public string Title { get; set; } 2250 public Image Image { get; set; } 2251 public string Text { get; set; } 2252 public string Link { get; set; } 2253 public bool SetImageAsBackground { get; set; } 2254 public bool HideOuterPadding { get; set; } 2255 public string InnerPaddingCss { get; set; } 2256 public string CardCss { get; set; } 2257 public string ButtonWrapperCss { get; set; } 2258 public string Layout { get; set; } 2259 public string Module { get; set; } 2260 public Link ButtonPrimary { get; set; } 2261 public Link ButtonSecondary { get; set; } 2262 } 2263 } 2264 2265 @helper RenderParagraph(ItemViewModel item, bool renderModule = true) 2266 { 2267 if (item != null) { 2268 string layout = item.GetList("ContentPositions").SelectedValue; 2269 2270 string paragraphClasses = ""; 2271 string paragraphWidth = !String.IsNullOrEmpty(item.GetString("Width")) ? item.GetList("Width").SelectedValue : "12"; 2272 paragraphClasses += " grid__col-lg-" + paragraphWidth + " grid__col-md-" + paragraphWidth + " grid__col-sm-" + paragraphWidth; 2273 if (item.GetList("WidthMobile").SelectedValue == "hide") 2274 { 2275 paragraphClasses += " u-hidden-xs"; 2276 } 2277 else 2278 { 2279 paragraphClasses += " grid__col-xs-" + item.GetList("WidthMobile").SelectedValue; 2280 } 2281 paragraphClasses += item.GetBoolean("HidePadding") ? " paragraph-container--no-padding" : ""; 2282 paragraphClasses += layout == "middle-center" || layout == "middle-left" ? " u-middle-horizontal grid--justify-center grid--align-self-center" : ""; 2283 2284 //Alternative Design Layout 2285 var designLayout = Model.Item.GetItem("CustomSettings") != null ? Model.Item.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.Item.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 2286 paragraphClasses += !String.IsNullOrEmpty(designLayout) ? designLayout : ""; 2287 2288 string title = item.GetBoolean("ShowTitle") ? item.GetString("Title") : ""; 2289 string cardClass = item.GetBoolean("ShowAsCard") ? "paragraph-card" : ""; 2290 string buttonSpacing = ""; 2291 string buttonAlignment = layout == "all-centered" || layout == "middle-center" ? "grid--justify-center" : ""; 2292 2293 string image = item.GetFile("Image") != null ? item.GetFile("Image").ToString() + "&" + item.GetFile("Image").GetFocalPointParameters() : ""; 2294 string imageNoUrlEncoded = item.GetFile("Image") != null ? item.GetFile("Image").Path : ""; 2295 2296 int cropMode = !String.IsNullOrEmpty(Converter.ToString(item.GetList("ImageCrop"))) ? Convert.ToInt32(item.GetList("ImageCrop").SelectedValue) : 0; 2297 ImageStyle imageStyle = item.GetList("ImageStyle").SelectedValue == "ball" ? ImageStyle.Ball : ImageStyle.None; 2298 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; 2299 if (primaryButtonLayout == ButtonLayout.Link) 2300 { 2301 primaryButtonLayout = ButtonLayout.LinkClean; 2302 } 2303 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; 2304 if (secondaryButtonLayout == ButtonLayout.Link) 2305 { 2306 secondaryButtonLayout = ButtonLayout.LinkClean; 2307 } 2308 ImageFilter primaryImageFilter = !string.IsNullOrEmpty(item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2309 ImageFilter secondaryImageFilter = !string.IsNullOrEmpty(item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2310 string imageFilterColorCode = item.GetString("ColorForTheFilter").StartsWith("#") && primaryImageFilter == ImageFilter.Colorize ? GenerateRgba(item.GetString("ColorForTheFilter"), 0.3) : ""; 2311 bool setImageAsBackground = item.GetList("ImageStyle").SelectedValue.ToLower() == "background" ? true : false; 2312 string altText = item.GetString("Title"); 2313 2314 // Get metadata for file 2315 Dynamicweb.Content.Files.Metadata.Meta m = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(Dynamicweb.Context.Current.Server.MapPath(imageNoUrlEncoded)); 2316 2317 if (string.IsNullOrEmpty(altText)) 2318 { 2319 if (m != null) 2320 { 2321 var lang = PageView.Current().Area.CultureInfo.TwoLetterISOLanguageName; 2322 switch (lang) 2323 { 2324 case "da": 2325 altText = m.GetValue("alttext_dk"); 2326 break; 2327 case "de": 2328 altText = m.GetValue("alttext_de"); 2329 break; 2330 case "fr": 2331 altText = m.GetValue("alttext_fr"); 2332 break; 2333 default: 2334 altText = m.GetValue("alttext"); 2335 break; 2336 } 2337 } 2338 } 2339 2340 Image paragraphImage = null; 2341 if (!String.IsNullOrEmpty(image)) 2342 { 2343 paragraphImage = new Image 2344 { 2345 Path = image, 2346 Link = item.GetString("Link"), 2347 FilterPrimary = primaryImageFilter, 2348 FilterSecondary = secondaryImageFilter, 2349 FilterColor = imageFilterColorCode, 2350 Style = imageStyle, 2351 Title = altText, 2352 ImageDefault = new ImageSettings 2353 { 2354 Crop = cropMode, 2355 Height = 845, 2356 Width = 1920 2357 }, 2358 ImageMedium = new ImageSettings 2359 { 2360 Crop = cropMode, 2361 Height = 450, 2362 Width = 1024 2363 }, 2364 ImageSmall = new ImageSettings 2365 { 2366 Crop = cropMode, 2367 Height = 544, 2368 Width = 640 2369 } 2370 }; 2371 } 2372 2373 ContentParagraph paragraph = new ContentParagraph 2374 { 2375 Title = title, 2376 Text = item.GetString("Text"), 2377 Image = paragraphImage, 2378 Link = item.GetString("Link"), 2379 Module = !String.IsNullOrEmpty(Model.GetModuleOutput()) && renderModule ? Model.GetModuleOutput() : "", 2380 InnerPaddingCss = item.GetList("InnerPadding") != null ? "paragraph-container__body--padding-" + item.GetList("InnerPadding").SelectedValue : "", 2381 CardCss = cardClass, 2382 HideOuterPadding = item.GetBoolean("HidePadding"), 2383 SetImageAsBackground = item.GetList("ImageStyle").SelectedValue.ToLower() == "background" ? true : false, 2384 ButtonWrapperCss = buttonSpacing + buttonAlignment, 2385 Layout = layout 2386 }; 2387 2388 if (!String.IsNullOrEmpty(item.GetString("Link"))) 2389 { 2390 paragraph.ButtonPrimary = new Link 2391 { 2392 Href = item.GetString("Link"), 2393 Title = item.GetString("LinkText"), 2394 ButtonLayout = primaryButtonLayout, 2395 CssClass = "u-no-margin" 2396 }; 2397 2398 if (!String.IsNullOrEmpty(item.GetString("SecondaryLink"))) { 2399 paragraph.ButtonPrimary.CssClass = ""; 2400 } 2401 } 2402 2403 if (!String.IsNullOrEmpty(item.GetString("SecondaryLink"))) 2404 { 2405 if (!String.IsNullOrEmpty(item.GetString("Link"))) 2406 { 2407 paragraph.ButtonPrimary.CssClass += " u-margin-right--lg"; 2408 } 2409 2410 paragraph.ButtonSecondary = new Link 2411 { 2412 Href = item.GetString("SecondaryLink"), 2413 Title = item.GetString("SecondaryLinkText"), 2414 ButtonLayout = secondaryButtonLayout 2415 }; 2416 } 2417 2418 <div class="paragraph-container @paragraphClasses dw-mod"> 2419 @if (setImageAsBackground == true && paragraphImage != null) 2420 { 2421 paragraphImage.CssClass = "background-image__cover"; 2422 2423 <div class="background-image dw-mod"> 2424 <div class="background-image__wrapper dw-mod"> 2425 @Render(paragraphImage) 2426 </div> 2427 </div> 2428 } 2429 @{ 2430 switch (layout) 2431 { 2432 case "title-top": 2433 @RenderLayoutTitleTop(paragraph) 2434 break; 2435 case "image-left": 2436 @RenderLayoutImageLeft(paragraph) 2437 break; 2438 case "image-right": 2439 @RenderLayoutImageRight(paragraph) 2440 break; 2441 case "image-centered": 2442 @RenderLayoutImageCentered(paragraph) 2443 break; 2444 case "all-centered": 2445 @RenderLayoutAllCentered(paragraph) 2446 break; 2447 case "middle-center": 2448 case "middle-left": 2449 @RenderLayoutMiddle(paragraph) 2450 break; 2451 default: 2452 @RenderLayoutImageTop(paragraph) 2453 break; 2454 } 2455 } 2456 </div> 2457 } 2458 } 2459 2460 2461 @helper RenderLayoutTitleTop(ContentParagraph settings) 2462 { 2463 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2464 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2465 @if (!settings.SetImageAsBackground && settings.Image != null) 2466 { 2467 <div class="u-margin-bottom--lg"> 2468 @Render(settings.Image) 2469 </div> 2470 } 2471 @Render(new Text { Content = settings.Text}) 2472 @Render(new ContentModule { Content = settings.Module }) 2473 2474 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2475 { 2476 <div class="grid__cell"> 2477 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2478 @Render(settings.ButtonPrimary) 2479 @Render(settings.ButtonSecondary) 2480 </div> 2481 </div> 2482 } 2483 </div> 2484 } 2485 2486 @helper RenderLayoutImageLeft(ContentParagraph settings) 2487 { 2488 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2489 <div class="grid grid--external-bleed"> 2490 @if (!settings.SetImageAsBackground && settings.Image != null) 2491 { 2492 <div class="grid__col-3"> 2493 @Render(settings.Image) 2494 </div> 2495 } 2496 <div class="grid__col-9 @settings.InnerPaddingCss dw-mod"> 2497 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2498 @Render(new Text { Content = settings.Text }) 2499 @Render(new ContentModule { Content = settings.Module }) 2500 2501 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2502 { 2503 <div class="grid__cell"> 2504 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2505 @Render(settings.ButtonPrimary) 2506 @Render(settings.ButtonSecondary) 2507 </div> 2508 </div> 2509 } 2510 </div> 2511 </div> 2512 </div> 2513 } 2514 2515 @helper RenderLayoutImageRight(ContentParagraph settings) 2516 { 2517 <div class="grid__cell @settings.CardCss"> 2518 <div class="grid grid--external-bleed"> 2519 <div class="grid__col-9 @settings.InnerPaddingCss dw-mod"> 2520 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2521 @Render(new Text { Content = settings.Text }) 2522 @Render(new ContentModule { Content = settings.Module }) 2523 2524 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2525 { 2526 <div class="grid__cell"> 2527 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2528 @Render(settings.ButtonPrimary) 2529 @Render(settings.ButtonSecondary) 2530 </div> 2531 </div> 2532 } 2533 </div> 2534 @if (!settings.SetImageAsBackground && settings.Image != null) 2535 { 2536 <div class="grid__col-3"> 2537 @Render(settings.Image) 2538 </div> 2539 } 2540 </div> 2541 </div> 2542 } 2543 2544 @helper RenderLayoutImageCentered(ContentParagraph settings) 2545 { 2546 <div class="grid__cell @settings.CardCss dw-mod"> 2547 2548 <div class="u-ta-center"> 2549 @if (!settings.SetImageAsBackground && settings.Image != null) 2550 { 2551 <div class="u-margin-bottom--lg u-inline-block"> 2552 @Render(settings.Image) 2553 </div> 2554 } 2555 </div> 2556 <div class="@settings.InnerPaddingCss dw-mod"> 2557 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2558 @Render(new Text { Content = settings.Text }) 2559 @Render(new ContentModule { Content = settings.Module }) 2560 2561 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2562 { 2563 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2564 @Render(settings.ButtonPrimary) 2565 @Render(settings.ButtonSecondary) 2566 </div> 2567 } 2568 </div> 2569 </div> 2570 } 2571 2572 @helper RenderLayoutAllCentered(ContentParagraph settings) 2573 { 2574 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2575 2576 <div class="u-ta-center"> 2577 @if (!settings.SetImageAsBackground && settings.Image != null) 2578 { 2579 <div class="u-margin-bottom--lg u-inline-block"> 2580 @Render(settings.Image) 2581 </div> 2582 } 2583 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2584 @Render(new Text { Content = settings.Text }) 2585 @Render(new ContentModule { Content = settings.Module }) 2586 </div> 2587 2588 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2589 { 2590 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2591 @Render(settings.ButtonPrimary) 2592 @Render(settings.ButtonSecondary) 2593 </div> 2594 } 2595 </div> 2596 } 2597 2598 @helper RenderLayoutMiddle(ContentParagraph settings) 2599 { 2600 <div> 2601 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2602 2603 <div class="@(settings.Layout == "middle-center" ? "u-ta-center" : "")"> 2604 @if (!settings.SetImageAsBackground && settings.Image != null) 2605 { 2606 <div class="u-margin-bottom--lg u-inline-block"> 2607 @Render(settings.Image) 2608 </div> 2609 } 2610 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2611 @Render(new Text { Content = settings.Text }) 2612 @Render(new ContentModule { Content = settings.Module }) 2613 </div> 2614 2615 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2616 { 2617 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2618 @Render(settings.ButtonPrimary) 2619 @Render(settings.ButtonSecondary) 2620 </div> 2621 } 2622 </div> 2623 </div> 2624 } 2625 2626 @helper RenderLayoutImageTop(ContentParagraph settings) 2627 { 2628 <div class="grid__cell @settings.CardCss"> 2629 @if (!settings.SetImageAsBackground && settings.Image != null) 2630 { 2631 <div class="u-margin-bottom--lg"> 2632 @Render(settings.Image) 2633 </div> 2634 } 2635 2636 <div class="@settings.InnerPaddingCss dw-mod"> 2637 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2638 @Render(new Text { Content = settings.Text }) 2639 @Render(new ContentModule { Content = settings.Module }) 2640 2641 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2642 { 2643 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2644 @Render(settings.ButtonPrimary) 2645 @Render(settings.ButtonSecondary) 2646 </div> 2647 } 2648 </div> 2649 </div> 2650 } 2651 2652 2653 @{ 2654 string fontColor = !string.IsNullOrEmpty(Model.Item.GetString("FontColor")) && !Model.Item.GetString("FontColor").StartsWith("#") ? "u-" + Model.Item.GetString("FontColor").Replace(" ", "-").ToLower() : ""; 2655 string backgroundColor = !string.IsNullOrEmpty(Model.Item.GetString("BackgroundColor")) && !Model.Item.GetString("BackgroundColor").StartsWith("#") ? "u-" + Model.Item.GetString("BackgroundColor").Replace(" ", "-").ToLower() + "--bg" : ""; 2656 string colorSettings = Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "style=\"" : ""; 2657 string fontColorHex = Model.Item.GetString("FontColor").StartsWith("#") ? "color: " + Model.Item.GetString("FontColor") + ";" : ""; 2658 string backgroundColorHex = Model.Item.GetString("BackgroundColor").StartsWith("#") ? "background-color: " + Model.Item.GetString("BackgroundColor") + ";" : ""; 2659 colorSettings += fontColorHex; 2660 colorSettings += backgroundColorHex; 2661 colorSettings += Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "\"" : ""; 2662 2663 string paragraphContainerClasses = ""; 2664 string containerClasses = ""; 2665 string gridClasses = ""; 2666 2667 string spacingSize = Model.Item.GetList("Spacing") != null && Model.Item.GetList("Spacing").SelectedValue != "" ? Model.Item.GetList("Spacing").SelectedValue : "lg"; 2668 string placeHolderImage = "/Files/Images/placeholder.gif"; 2669 int columnCount = 0; 2670 int paragraphCount = 0; 2671 int totalParagraphs = Model.Item.GetItems("Paragraph").Count; 2672 int totalSlides = 1; 2673 2674 switch (Model.Item.GetList("Width").SelectedValue) 2675 { 2676 case "center": 2677 containerClasses += "center-container paragraph-container "; 2678 paragraphContainerClasses += " " + fontColor + " " + backgroundColor; 2679 break; 2680 case "full": 2681 containerClasses += fontColor + " " + backgroundColor + " "; 2682 paragraphContainerClasses += "paragraph-container--full-width "; 2683 break; 2684 case "combi": 2685 paragraphContainerClasses += "paragraph-container--full-width " + fontColor + " " + backgroundColor + " "; 2686 containerClasses += "center-container paragraph-container "; 2687 break; 2688 default: 2689 paragraphContainerClasses += "center-container "; 2690 break; 2691 } 2692 2693 if (spacingSize == "none") 2694 { 2695 containerClasses += "paragraph-container--spacing-none "; 2696 } 2697 2698 //Background 2699 string containerBackgroundImage = ""; 2700 string containerBackgroundImagePure = ""; 2701 string containerBackgroundImageLarge = ""; 2702 string containerBackgroundImageMedium = ""; 2703 string containerBackgroundImageSmall = ""; 2704 string containerBackgroundAltText = ""; 2705 2706 string focalPointParameters = Model.Item.GetFile("BackgroundImage") != null ? "&" + Model.Item.GetFile("BackgroundImage").GetFocalPointParameters() : ""; 2707 2708 string containerBackgroundImageFilterColor = Model.Item.GetList("ColorForTheFilter") != null ? Model.Item.GetString("ColorForTheFilter").Replace(" ", "-").ToLower() : "none"; 2709 string containerBackgroundImageFilterPrimary = Model.Item.GetList("ImageFilterPrimary") != null ? Model.Item.GetList("ImageFilterPrimary").SelectedValue : "none"; 2710 string containerBackgroundImageFilterSecondary = Model.Item.GetList("ImageFilterSecondary") != null ? Model.Item.GetList("ImageFilterSecondary").SelectedValue : "none"; 2711 string containerBackgroundImageFilterColorCode = Model.Item.GetString("ColorForTheFilter").StartsWith("#") && containerBackgroundImageFilterPrimary == "colorize" ? "style=\"background-color: " + GenerateRgba(Model.Item.GetString("ColorForTheFilter"), 0.3) + "\"" : ""; 2712 2713 if (containerBackgroundImageFilterPrimary == "colorize" && !containerBackgroundImageFilterPrimary.StartsWith("#")) 2714 { 2715 containerBackgroundImageFilterPrimary = containerBackgroundImageFilterColor; 2716 } 2717 2718 /* Custom */ 2719 if (Model.Item.GetFile("BackgroundImage") != null) 2720 { 2721 containerBackgroundImage = "/Admin/Public/GetImage.ashx?width=2500&amp;height=1100&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 2722 containerBackgroundImagePure = Model.Item.GetFile("BackgroundImage").Path; 2723 containerBackgroundImageLarge = "/Admin/Public/GetImage.ashx?width=1920&amp;height=845&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 2724 containerBackgroundImageMedium = "/Admin/Public/GetImage.ashx?width=1024&amp;height=450&amp;crop=0&amp;&amp;FillCanvas=TrueCompression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 2725 containerBackgroundImageSmall = "/Admin/Public/GetImage.ashx?width=640&amp;height=544&amp;crop=0&amp;&amp;FillCanvas=TrueCompression=85&amp;DoNotUpscale=true&amp;image=" + Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters; 2726 2727 // Get metadata for file 2728 Dynamicweb.Content.Files.Metadata.Meta m = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(Dynamicweb.Context.Current.Server.MapPath(containerBackgroundImagePure)); 2729 2730 if (m != null) 2731 { 2732 var lang = PageView.Current().Area.CultureInfo.TwoLetterISOLanguageName; 2733 switch (lang) 2734 { 2735 case "da": 2736 containerBackgroundAltText = m.GetValue("alttext_dk"); 2737 break; 2738 case "de": 2739 containerBackgroundAltText = m.GetValue("alttext_de"); 2740 break; 2741 case "fr": 2742 containerBackgroundAltText = m.GetValue("alttext_fr"); 2743 break; 2744 default: 2745 containerBackgroundAltText = m.GetValue("alttext"); 2746 break; 2747 } 2748 } 2749 } 2750 else if (string.IsNullOrEmpty(backgroundColor)) 2751 { 2752 backgroundColor = "u-color-light--bg"; 2753 } 2754 2755 //Separation line 2756 bool hasSeparationLine = Model.Item.GetBoolean("SeperationLineAfter"); 2757 if (hasSeparationLine && Model.Item.GetList("Width").SelectedValue != "center") 2758 { 2759 paragraphContainerClasses += "multiple-paragraphs-container--seperation-line-after "; 2760 } 2761 else if (hasSeparationLine) 2762 { 2763 containerClasses += "multiple-paragraphs-container--seperation-line-after "; 2764 } 2765 2766 //Alternative Design Layout 2767 var designLayout = Model.Item.GetItem("CustomSettings") != null ? Model.Item.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.Item.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 2768 paragraphContainerClasses += !String.IsNullOrEmpty(designLayout) ? designLayout : ""; 2769 2770 var paragraphHeight = Model.Item.GetList("Height").SelectedValue; 2771 //Height 2772 if (!string.IsNullOrEmpty(paragraphHeight)) 2773 { 2774 gridClasses += "paragraph-container--height-" + paragraphHeight + " " + (paragraphHeight == "screen" ? "screen-height " : ""); 2775 } 2776 2777 if (Model.Item.GetString("MakeParagraphsCenterAligned") != null && Model.Item.GetBoolean("MakeParagraphsCenterAligned")) 2778 { 2779 gridClasses += "grid--justify-center "; 2780 } 2781 2782 //Set as carousel 2783 if (Model.Item.GetBoolean("EnableCarousel")) 2784 { 2785 containerClasses.Replace(" paragraph-container ", ""); 2786 } 2787 2788 //getting video ID from youtube URL 2789 string videoCode = Model.Item.GetString("VideoURL"); 2790 Regex regex = new Regex(@".be\/(.[^?]*)"); 2791 Match match = regex.Match(videoCode); 2792 string videoId = ""; 2793 if (match.Success) 2794 { 2795 videoId = match.Groups[1].Value; 2796 } 2797 else 2798 { 2799 regex = new Regex(@"v=([^&]+)"); 2800 match = regex.Match(videoCode); 2801 if (match.Success) 2802 { 2803 videoId = match.Groups[1].Value; 2804 } 2805 } 2806 } 2807 2808 <div class="grid__col-md-12 grid__col--bleed"> 2809 <section class="multiple-paragraphs-container @paragraphContainerClasses multiple-paragraphs-container--spacing-@spacingSize dw-mod" @colorSettings> 2810 <div class="background-image image-filter image-filter--@containerBackgroundImageFilterPrimary dw-mod" @containerBackgroundImageFilterColorCode> 2811 <div class="background-image__wrapper image-filter image-filter--@containerBackgroundImageFilterSecondary dw-mod"> 2812 @if (!String.IsNullOrEmpty(Model.Item.GetString("BackgroundImage"))) { 2813 @Render(new Image { 2814 Path = Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters, 2815 CssClass = "background-image__cover", 2816 DisableLazyLoad = false, 2817 Title = containerBackgroundAltText, 2818 ImageDefault = new ImageSettings { 2819 Width = 1920, 2820 Height = 845, 2821 Crop = 0, 2822 FillCanvas = true 2823 }, 2824 ImageMedium = new ImageSettings 2825 { 2826 Width = 1024, 2827 Height = 450, 2828 Crop = 0, 2829 FillCanvas = true 2830 }, 2831 ImageSmall = new ImageSettings 2832 { 2833 Width = 640, 2834 Height = 544, 2835 Crop = 0, 2836 FillCanvas = true 2837 } 2838 }) 2839 } 2840 2841 @if (!string.IsNullOrEmpty(videoId)) 2842 { 2843 <div class="video-background"> 2844 <div class="video-background__container"> 2845 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Model.ID)"></div> 2846 </div> 2847 </div> 2848 } 2849 </div> 2850 </div> 2851 2852 @if (!Model.Item.GetBoolean("EnableCarousel")) 2853 { 2854 <div class="@containerClasses dw-mod"> 2855 <div class="grid @gridClasses dw-mod"> 2856 @foreach (var paragraph in Model.Item.GetItems("Paragraph")) 2857 { 2858 @RenderParagraph(paragraph, false) 2859 } 2860 @if (!String.IsNullOrEmpty(Model.GetModuleOutput())) { 2861 <div class="paragraph-container grid__col-12 dw-mod"> 2862 @Render(new ContentModule { Content = Model.GetModuleOutput() }) 2863 </div> 2864 } 2865 </div> 2866 </div> 2867 } 2868 else 2869 { 2870 var slides = new List<List<Dynamicweb.Frontend.ItemViewModel>>(); 2871 int tempColumnsCount = 0; 2872 var paragraphs = Model.Item.GetItems("Paragraph"); 2873 bool hasAtLeastOneVisibleParagraph = false; 2874 if (paragraphs.Count > 0) 2875 { 2876 slides.Add(new List<Dynamicweb.Frontend.ItemViewModel>()); 2877 } 2878 2879 foreach (var paragraph in paragraphs) 2880 { 2881 int columnWidth = 0; 2882 if (Pageview.Device.ToString() == "Mobile" && paragraph.GetList("WidthMobile").SelectedValue == "hide") 2883 { 2884 continue; 2885 } 2886 hasAtLeastOneVisibleParagraph = true; 2887 if (paragraph.GetList("Width").SelectedValue != "auto") 2888 { 2889 columnWidth = Pageview.Device.ToString() != "Mobile" ? Int32.Parse(paragraph.GetList("Width").SelectedValue) : Int32.Parse(paragraph.GetList("WidthMobile").SelectedValue); 2890 } 2891 else 2892 { 2893 columnWidth = 1; 2894 } 2895 2896 if (tempColumnsCount + columnWidth > 12) 2897 { 2898 slides.Add(new List<Dynamicweb.Frontend.ItemViewModel>()); 2899 tempColumnsCount = 0; 2900 } 2901 2902 slides[slides.Count - 1].Add(paragraph); 2903 tempColumnsCount += columnWidth; 2904 } 2905 2906 if (hasAtLeastOneVisibleParagraph) 2907 { 2908 <div class="@containerClasses dw-mod"> 2909 <div class="carousel dw-mod" id="Paragraph_@(Model.ID)"> 2910 <div class="carousel__container js-carousel-slides dw-mod"> 2911 @foreach (var slide in slides) 2912 { 2913 <div class="carousel__slide dw-mod"> 2914 <div class="grid @gridClasses dw-mod"> 2915 @foreach (var paragraph in slide) 2916 { 2917 @RenderParagraph(paragraph, false) 2918 } 2919 </div> 2920 </div> 2921 } 2922 </div> 2923 </div> 2924 </div> 2925 } 2926 2927 if (slides.Count > 1) 2928 { 2929 bool enableDots = Model.Item.GetBoolean("ShowDots"); 2930 2931 <script> 2932 document.addEventListener("DOMContentLoaded", function () { 2933 new CarouselModule("#Paragraph_@(Model.ID)", { 2934 slideTime: @Model.Item.GetString("SlideTime"), 2935 dots: @(Model.Item.GetBoolean("ShowDots").ToString().ToLower()) 2936 }); 2937 }) 2938 </script> 2939 } 2940 } 2941 </section> 2942 </div> 2943

tekst

space