Audio/lighting & stage specialists Buy new and 2nd hand
Error executing template "Designs/Rapido/eCom/Productlist/ProductsRender.cshtml"
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Text.StringBuilder.ToString()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.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 RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, ITemplateSource templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb.Frontend.Devices 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Content 5 @using Dynamicweb.Core 6 @using System 7 @using System.IO 8 @using System.Web 9 @using System.Collections.Generic; 10 @using System.Linq 11 @using System.Text.RegularExpressions 12 @using Dynamicweb.Rapido.Blocks 13 14 @functions { 15 BlocksPage productListPage = BlocksPage.GetBlockPage("ProductList"); 16 string favoriteListId = HttpContext.Current.Request.QueryString.Get("ListID"); 17 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID")); 18 } 19 20 @{ 21 Block pageContainer = new Block() 22 { 23 Id = "PageContainer", 24 Template = RenderPageContainer(), 25 SkipRenderBlocksList = true 26 }; 27 productListPage.Add(pageContainer); 28 29 Block productListNavigation = new Block() 30 { 31 Id = "Navigation", 32 SortId = 20, 33 Design = new Design 34 { 35 RenderType = RenderType.Column, 36 Size = "3" 37 } 38 }; 39 productListPage.Add("PageContainer", productListNavigation); 40 41 Block productListContainer = new Block() 42 { 43 Id = "ProductList", 44 SortId = 30, 45 Template = RenderProductList(), 46 SkipRenderBlocksList = true, 47 BlocksList = new List<Block> 48 { 49 new Block 50 { 51 Id = "ProductListHeader", 52 SortId = 10, 53 Design = new Design 54 { 55 RenderType = RenderType.Row, 56 CssClass = "grid--justify-end grid--bleed u-margin-bottom--lg grid--wrap u-flex-grow--0" 57 }, 58 BlocksList = new List<Block> 59 { 60 new Block 61 { 62 Id = "ProductListTitle", 63 SortId = 10, 64 Design = new Design 65 { 66 CssClass = "grid__col-sm-6" 67 }, 68 Template = RenderProductListTitle() 69 } 70 } 71 } 72 } 73 }; 74 productListPage.Add("PageContainer", productListContainer); 75 76 if (isFavoriteList) 77 { 78 productListPage.Add("ProductListHeader", new Block 79 { 80 Id = "FavoriteListSearch", 81 SortId = 20, 82 Template = RenderFavoriteListSearch(), 83 Design = new Design 84 { 85 CssClass = "grid__col-sm-6 u-margin-bottom u-margin-top grid--align-self-center" 86 } 87 }); 88 } 89 90 Block productListSnippets = new Block() 91 { 92 Id = "BottomSnippets", 93 SortId = 40 94 }; 95 productListPage.Add(productListSnippets); 96 } 97 98 @* This is required for the product list feed to work *@ 99 @GetValue("DoNotRenderProductListTemplate") 100 101 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 102 @using System.Text.RegularExpressions 103 @using System.Collections.Generic 104 @using System.Reflection 105 @using System.Web 106 @using System.Web.UI.HtmlControls 107 @using Dynamicweb.Rapido.Blocks.Components 108 @using Dynamicweb.Rapido.Blocks.Components.Articles 109 @using Dynamicweb.Rapido.Blocks.Components.Documentation 110 @using Dynamicweb.Rapido.Blocks 111 112 113 @*--- START: Base block renderers ---*@ 114 115 @helper RenderBlockList(List<Block> blocks) 116 { 117 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 118 blocks = blocks.OrderBy(item => item.SortId).ToList(); 119 120 foreach (Block item in blocks) 121 { 122 if (debug) { 123 <!-- Block START: @item.Id --> 124 } 125 126 if (item.Design == null) 127 { 128 @RenderBlock(item) 129 } 130 else if (item.Design.RenderType == RenderType.None) { 131 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 132 133 <div class="@cssClass dw-mod"> 134 @RenderBlock(item) 135 </div> 136 } 137 else if (item.Design.RenderType != RenderType.Hide) 138 { 139 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 140 141 if (!item.SkipRenderBlocksList) { 142 if (item.Design.RenderType == RenderType.Row) 143 { 144 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 145 @RenderBlock(item) 146 </div> 147 } 148 149 if (item.Design.RenderType == RenderType.Column) 150 { 151 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 152 string size = item.Design.Size ?? "12"; 153 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 154 155 <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"> 156 @RenderBlock(item) 157 </div> 158 } 159 160 if (item.Design.RenderType == RenderType.Table) 161 { 162 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 163 @RenderBlock(item) 164 </table> 165 } 166 167 if (item.Design.RenderType == RenderType.TableRow) 168 { 169 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 170 @RenderBlock(item) 171 </tr> 172 } 173 174 if (item.Design.RenderType == RenderType.TableColumn) 175 { 176 <td class="@cssClass dw-mod" id="Block__@item.Id"> 177 @RenderBlock(item) 178 </td> 179 } 180 181 if (item.Design.RenderType == RenderType.CardHeader) 182 { 183 <div class="card-header @cssClass dw-mod"> 184 @RenderBlock(item) 185 </div> 186 } 187 188 if (item.Design.RenderType == RenderType.CardBody) 189 { 190 <div class="card @cssClass dw-mod"> 191 @RenderBlock(item) 192 </div> 193 } 194 195 if (item.Design.RenderType == RenderType.CardFooter) 196 { 197 <div class="card-footer @cssClass dw-mod"> 198 @RenderBlock(item) 199 </div> 200 } 201 } 202 else 203 { 204 @RenderBlock(item) 205 } 206 } 207 208 if (debug) { 209 <!-- Block END: @item.Id --> 210 } 211 } 212 } 213 214 @helper RenderBlock(Block item) 215 { 216 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 217 218 if (item.Template != null) 219 { 220 @BlocksPage.RenderTemplate(item.Template) 221 } 222 223 if (item.Component != null) 224 { 225 string customSufix = "Custom"; 226 string methodName = item.Component.HelperName; 227 228 ComponentBase[] methodParameters = new ComponentBase[1]; 229 methodParameters[0] = item.Component; 230 Type methodType = this.GetType(); 231 232 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 233 MethodInfo generalMethod = methodType.GetMethod(methodName); 234 235 try { 236 if (debug) { 237 <!-- Component: @methodName.Replace("Render", "") --> 238 } 239 @customMethod.Invoke(this, methodParameters).ToString(); 240 } catch { 241 try { 242 @generalMethod.Invoke(this, methodParameters).ToString(); 243 } catch(Exception ex) { 244 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 245 } 246 } 247 } 248 249 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 250 { 251 @RenderBlockList(item.BlocksList) 252 } 253 } 254 255 @*--- END: Base block renderers ---*@ 256 257 @using Dynamicweb.Rapido.Blocks.Components 258 @using Dynamicweb.Rapido.Blocks.Components.General 259 @using Dynamicweb.Rapido.Blocks 260 @using System.IO 261 262 @* Required *@ 263 @using Dynamicweb.Rapido.Blocks.Components 264 @using Dynamicweb.Rapido.Blocks.Components.General 265 @using Dynamicweb.Rapido.Blocks 266 267 268 @helper Render(ComponentBase component) 269 { 270 if (component != null) 271 { 272 @component.Render(this) 273 } 274 } 275 276 277 @* Components *@ 278 @using System.Reflection 279 @using Dynamicweb.Rapido.Blocks.Components.General 280 281 282 @* Component *@ 283 284 @helper RenderIcon(Icon settings) 285 { 286 if (settings != null) 287 { 288 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 289 290 if (settings.Name != null) 291 { 292 if (string.IsNullOrEmpty(settings.Label)) 293 { 294 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 295 } 296 else 297 { 298 if (settings.LabelPosition == IconLabelPosition.Before) 299 { 300 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 301 } 302 else 303 { 304 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 305 } 306 } 307 } 308 else if (!string.IsNullOrEmpty(settings.Label)) 309 { 310 @settings.Label 311 } 312 } 313 } 314 @using System.Reflection 315 @using Dynamicweb.Rapido.Blocks.Components.General 316 @using Dynamicweb.Rapido.Blocks.Components 317 @using Dynamicweb.Core 318 319 @* Component *@ 320 321 @helper RenderButton(Button settings) 322 { 323 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 324 { 325 Dictionary<string, string> attributes = new Dictionary<string, string>(); 326 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 327 if (settings.Disabled) { 328 attributes.Add("disabled", "true"); 329 classList.Add("disabled"); 330 } 331 332 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 333 { 334 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 335 @RenderConfirmDialog(settings); 336 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 337 } 338 339 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 340 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 341 if (!string.IsNullOrEmpty(settings.AltText)) 342 { 343 attributes.Add("title", settings.AltText); 344 } 345 else if (!string.IsNullOrEmpty(settings.Title)) 346 { 347 attributes.Add("title", settings.Title); 348 } 349 350 var onClickEvents = new List<string>(); 351 if (!string.IsNullOrEmpty(settings.OnClick)) 352 { 353 onClickEvents.Add(settings.OnClick); 354 } 355 if (!string.IsNullOrEmpty(settings.Href)) 356 { 357 onClickEvents.Add("location.href='" + settings.Href + "'"); 358 } 359 if (onClickEvents.Count > 0) 360 { 361 attributes.Add("onClick", string.Join(";", onClickEvents)); 362 } 363 364 if (settings.ButtonLayout != ButtonLayout.None) 365 { 366 classList.Add("btn"); 367 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 368 if (btnLayout == "linkclean") 369 { 370 btnLayout = "link-clean"; //fix 371 } 372 classList.Add("btn--" + btnLayout); 373 } 374 375 if (settings.Icon == null) 376 { 377 settings.Icon = new Icon(); 378 } 379 settings.Icon.Label = settings.Title; 380 381 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 382 383 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 384 } 385 } 386 387 @helper RenderConfirmDialog(Button settings) 388 { 389 Modal confirmDialog = new Modal { 390 Id = settings.Id, 391 Width = ModalWidth.Sm, 392 Heading = new Heading 393 { 394 Level = 2, 395 Title = settings.ConfirmTitle 396 }, 397 BodyText = settings.ConfirmText 398 }; 399 400 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 401 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 402 403 @Render(confirmDialog) 404 } 405 @using Dynamicweb.Rapido.Blocks.Components.General 406 @using Dynamicweb.Rapido.Blocks.Components 407 @using Dynamicweb.Core 408 409 @helper RenderDashboard(Dashboard settings) 410 { 411 var widgets = settings.GetWidgets(); 412 413 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 414 { 415 //set bg color for them 416 417 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 418 int r = Convert.ToInt16(color.R); 419 int g = Convert.ToInt16(color.G); 420 int b = Convert.ToInt16(color.B); 421 422 var count = widgets.Length; 423 var max = Math.Max(r, Math.Max(g, b)); 424 double step = 255.0 / (max * count); 425 var i = 0; 426 foreach (var widget in widgets) 427 { 428 i++; 429 430 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 431 widget.BackgroundColor = shade; 432 } 433 } 434 435 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 436 @foreach (var widget in widgets) 437 { 438 <div class="dashboard__widget"> 439 @Render(widget) 440 </div> 441 } 442 </div> 443 } 444 @using Dynamicweb.Rapido.Blocks.Components.General 445 @using Dynamicweb.Rapido.Blocks.Components 446 447 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 448 { 449 if (!string.IsNullOrEmpty(settings.Link)) 450 { 451 var backgroundStyles = ""; 452 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 453 { 454 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 455 } 456 457 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 458 <div class="u-center-middle u-color-light"> 459 @if (settings.Icon != null) 460 { 461 settings.Icon.CssClass += "widget__icon"; 462 @Render(settings.Icon) 463 } 464 <div class="widget__title">@settings.Title</div> 465 </div> 466 </a> 467 } 468 } 469 @using Dynamicweb.Rapido.Blocks.Components.General 470 @using Dynamicweb.Rapido.Blocks.Components 471 472 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 473 { 474 var backgroundStyles = ""; 475 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 476 { 477 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 478 } 479 480 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 481 <div class="u-center-middle u-color-light"> 482 @if (settings.Icon != null) 483 { 484 settings.Icon.CssClass += "widget__icon"; 485 @Render(settings.Icon) 486 } 487 <div class="widget__counter">@settings.Count</div> 488 <div class="widget__title">@settings.Title</div> 489 </div> 490 </div> 491 } 492 @using System.Reflection 493 @using Dynamicweb.Rapido.Blocks.Components.General 494 @using Dynamicweb.Rapido.Blocks.Components 495 @using Dynamicweb.Core 496 497 @* Component *@ 498 499 @helper RenderLink(Link settings) 500 { 501 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 502 { 503 Dictionary<string, string> attributes = new Dictionary<string, string>(); 504 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 505 if (settings.Disabled) 506 { 507 attributes.Add("disabled", "true"); 508 classList.Add("disabled"); 509 } 510 511 if (!string.IsNullOrEmpty(settings.AltText)) 512 { 513 attributes.Add("title", settings.AltText); 514 } 515 else if (!string.IsNullOrEmpty(settings.Title)) 516 { 517 attributes.Add("title", settings.Title); 518 } 519 520 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 521 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 522 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 523 attributes.Add("href", settings.Href); 524 525 if (settings.ButtonLayout != ButtonLayout.None) 526 { 527 classList.Add("btn"); 528 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 529 if (btnLayout == "linkclean") 530 { 531 btnLayout = "link-clean"; //fix 532 } 533 classList.Add("btn--" + btnLayout); 534 } 535 536 if (settings.Icon == null) 537 { 538 settings.Icon = new Icon(); 539 } 540 settings.Icon.Label = settings.Title; 541 542 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 543 { 544 settings.Rel = LinkRelType.Noopener; 545 } 546 if (settings.Target != LinkTargetType.None) 547 { 548 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 549 } 550 if (settings.Download) 551 { 552 attributes.Add("download", "true"); 553 } 554 if (settings.Rel != LinkRelType.None) 555 { 556 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 557 } 558 559 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 560 } 561 } 562 @using System.Reflection 563 @using Dynamicweb.Rapido.Blocks.Components 564 @using Dynamicweb.Rapido.Blocks.Components.General 565 @using Dynamicweb.Rapido.Blocks 566 567 568 @* Component *@ 569 570 @helper RenderRating(Rating settings) 571 { 572 if (settings.Score > 0) 573 { 574 int rating = settings.Score; 575 string iconType = "fa-star"; 576 577 switch (settings.Type.ToString()) { 578 case "Stars": 579 iconType = "fa-star"; 580 break; 581 case "Hearts": 582 iconType = "fa-heart"; 583 break; 584 case "Lemons": 585 iconType = "fa-lemon"; 586 break; 587 case "Bombs": 588 iconType = "fa-bomb"; 589 break; 590 } 591 592 <div class="u-ta-right"> 593 @for (int i = 0; i < settings.OutOf; i++) 594 { 595 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 596 } 597 </div> 598 } 599 } 600 @using System.Reflection 601 @using Dynamicweb.Rapido.Blocks.Components.General 602 @using Dynamicweb.Rapido.Blocks.Components 603 604 605 @* Component *@ 606 607 @helper RenderSelectFieldOption(SelectFieldOption settings) 608 { 609 Dictionary<string, string> attributes = new Dictionary<string, string>(); 610 if (settings.Checked) { attributes.Add("selected", "true"); } 611 if (settings.Disabled) { attributes.Add("disabled", "true"); } 612 if (settings.Value != null) { attributes.Add("value", settings.Value); } 613 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 614 615 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 616 } 617 @using System.Reflection 618 @using Dynamicweb.Rapido.Blocks.Components.General 619 @using Dynamicweb.Rapido.Blocks.Components 620 621 622 @* Component *@ 623 624 @helper RenderNavigation(Navigation settings) { 625 @RenderNavigation(new 626 { 627 id = settings.Id, 628 cssclass = settings.CssClass, 629 startLevel = settings.StartLevel, 630 endlevel = settings.EndLevel, 631 expandmode = settings.Expandmode, 632 sitemapmode = settings.SitemapMode, 633 template = settings.Template 634 }) 635 } 636 @using Dynamicweb.Rapido.Blocks.Components.General 637 @using Dynamicweb.Rapido.Blocks.Components 638 639 640 @* Component *@ 641 642 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 643 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 644 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 645 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 646 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 647 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 648 settings.SitemapMode = false; 649 650 @RenderNavigation(settings) 651 } 652 @using Dynamicweb.Rapido.Blocks.Components.General 653 @using Dynamicweb.Rapido.Blocks.Components 654 655 656 @* Component *@ 657 658 @helper RenderLeftNavigation(LeftNavigation settings) { 659 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 660 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 661 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 662 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 663 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 664 665 <div class="grid__cell"> 666 @RenderNavigation(settings) 667 </div> 668 } 669 @using System.Reflection 670 @using Dynamicweb.Rapido.Blocks.Components.General 671 @using Dynamicweb.Core 672 673 @* Component *@ 674 675 @helper RenderHeading(Heading settings) 676 { 677 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 678 { 679 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 680 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 681 682 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 683 if (!string.IsNullOrEmpty(settings.Link)) 684 { 685 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 686 } 687 else 688 { 689 if (settings.Icon == null) 690 { 691 settings.Icon = new Icon(); 692 } 693 settings.Icon.Label = settings.Title; 694 @Render(settings.Icon) 695 } 696 @("</" + tagName + ">"); 697 } 698 } 699 @using Dynamicweb.Rapido.Blocks.Components 700 @using Dynamicweb.Rapido.Blocks.Components.General 701 @using Dynamicweb.Rapido.Blocks 702 703 704 @* Component *@ 705 706 @helper RenderImage(Image settings) 707 { 708 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 709 { 710 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 711 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 712 713 if (settings.Caption != null) 714 { 715 @:<div> 716 } 717 718 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 719 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 720 721 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 722 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 723 @if (settings.Link != null) 724 { 725 <a href="@settings.Link"> 726 @RenderTheImage(settings) 727 </a> 728 } 729 else 730 { 731 @RenderTheImage(settings) 732 } 733 </div> 734 </div> 735 736 if (settings.Caption != null) 737 { 738 <span class="image-caption dw-mod">@settings.Caption</span> 739 @:</div> 740 } 741 } 742 else 743 { 744 if (settings.Caption != null) 745 { 746 @:<div> 747 } 748 if (!string.IsNullOrEmpty(settings.Link)) 749 { 750 <a href="@settings.Link"> 751 @RenderTheImage(settings) 752 </a> 753 } 754 else 755 { 756 @RenderTheImage(settings) 757 } 758 759 if (settings.Caption != null) 760 { 761 <span class="image-caption dw-mod">@settings.Caption</span> 762 @:</div> 763 } 764 } 765 } 766 767 @helper RenderTheImage(Image settings) 768 { 769 if (settings != null) 770 { 771 string placeholderImage = "/Files/Images/placeholder.gif"; 772 string imageEngine = "/Admin/Public/GetImage.ashx?"; 773 774 string imageStyle = ""; 775 776 switch (settings.Style) 777 { 778 case ImageStyle.Ball: 779 imageStyle = "grid__cell-img--ball"; 780 break; 781 } 782 783 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 784 { 785 if (settings.ImageDefault != null) 786 { 787 settings.ImageDefault.Height = settings.ImageDefault.Width; 788 } 789 if (settings.ImageMedium != null) 790 { 791 settings.ImageMedium.Height = settings.ImageMedium.Width; 792 } 793 if (settings.ImageSmall != null) 794 { 795 settings.ImageSmall.Height = settings.ImageSmall.Width; 796 } 797 } 798 799 string defaultImage = imageEngine; 800 string imageSmall = ""; 801 string imageMedium = ""; 802 803 if (settings.DisableImageEngine) 804 { 805 defaultImage = settings.Path; 806 } 807 else 808 { 809 if (settings.ImageDefault != null) 810 { 811 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 812 813 if (settings.Path.GetType() != typeof(string)) 814 { 815 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 816 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 817 } 818 else 819 { 820 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 821 } 822 } 823 824 if (settings.ImageSmall != null) 825 { 826 imageSmall = "data-src-small=\"" + imageEngine; 827 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 828 829 if (settings.Path.GetType() != typeof(string)) 830 { 831 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 832 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 833 } 834 else 835 { 836 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 837 } 838 839 imageSmall += "\""; 840 } 841 842 if (settings.ImageMedium != null) 843 { 844 imageMedium = "data-src-medium=\"" + imageEngine; 845 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 846 847 if (settings.Path.GetType() != typeof(string)) 848 { 849 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 850 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 851 } 852 else 853 { 854 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 855 } 856 857 imageMedium += "\""; 858 } 859 } 860 861 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 862 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 863 if (!string.IsNullOrEmpty(settings.Title)) 864 { 865 optionalAttributes.Add("alt", settings.Title); 866 optionalAttributes.Add("title", settings.Title); 867 } 868 869 if (settings.DisableLazyLoad) 870 { 871 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 872 } 873 else 874 { 875 <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) /> 876 } 877 } 878 } 879 @using System.Reflection 880 @using Dynamicweb.Rapido.Blocks.Components.General 881 @using Dynamicweb.Rapido.Blocks.Components 882 883 @* Component *@ 884 885 @helper RenderFileField(FileField settings) 886 { 887 var attributes = new Dictionary<string, string>(); 888 if (string.IsNullOrEmpty(settings.Id)) 889 { 890 settings.Id = Guid.NewGuid().ToString("N"); 891 } 892 893 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 894 if (settings.Disabled) { attributes.Add("disabled", "true"); } 895 if (settings.Required) { attributes.Add("required", "true"); } 896 if (settings.Multiple) { attributes.Add("multiple", "true"); } 897 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 898 if (string.IsNullOrEmpty(settings.ChooseFileText)) 899 { 900 settings.ChooseFileText = Translate("Choose file"); 901 } 902 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 903 { 904 settings.NoFilesChosenText = Translate("No files chosen..."); 905 } 906 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 907 908 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 909 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 910 911 attributes.Add("type", "file"); 912 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 913 settings.CssClass = "u-full-width " + settings.CssClass; 914 915 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 916 917 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 918 @if (!string.IsNullOrEmpty(settings.Label)) 919 { 920 <label for="@settings.Id">@settings.Label</label> 921 } 922 @if (!string.IsNullOrEmpty(settings.HelpText)) 923 { 924 <small class="form__help-text">@settings.HelpText</small> 925 } 926 927 <div class="form__field-combi file-input u-no-margin dw-mod"> 928 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 929 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 930 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 931 @if (settings.UploadButton != null) 932 { 933 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 934 @Render(settings.UploadButton) 935 } 936 </div> 937 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 938 </div> 939 } 940 @using System.Reflection 941 @using Dynamicweb.Rapido.Blocks.Components.General 942 @using Dynamicweb.Rapido.Blocks.Components 943 @using Dynamicweb.Core 944 @using System.Linq 945 946 @* Component *@ 947 948 @helper RenderDateTimeField(DateTimeField settings) 949 { 950 if (string.IsNullOrEmpty(settings.Id)) 951 { 952 settings.Id = Guid.NewGuid().ToString("N"); 953 } 954 955 var textField = new TextField { 956 Name = settings.Name, 957 Id = settings.Id, 958 Label = settings.Label, 959 HelpText = settings.HelpText, 960 Value = settings.Value, 961 Disabled = settings.Disabled, 962 Required = settings.Required, 963 ErrorMessage = settings.ErrorMessage, 964 CssClass = settings.CssClass, 965 WrapperCssClass = settings.WrapperCssClass, 966 OnChange = settings.OnChange, 967 OnClick = settings.OnClick, 968 ExtraAttributes = settings.ExtraAttributes, 969 // 970 Placeholder = settings.Placeholder 971 }; 972 973 @Render(textField) 974 975 List<string> jsAttributes = new List<string>(); 976 977 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 978 979 if (!string.IsNullOrEmpty(settings.DateFormat)) 980 { 981 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 982 } 983 if (!string.IsNullOrEmpty(settings.MinDate)) 984 { 985 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 986 } 987 if (!string.IsNullOrEmpty(settings.MaxDate)) 988 { 989 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 990 } 991 if (settings.IsInline) 992 { 993 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 994 } 995 if (settings.EnableTime) 996 { 997 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 998 } 999 if (settings.EnableWeekNumbers) 1000 { 1001 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1002 } 1003 1004 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1005 1006 <script> 1007 document.addEventListener("DOMContentLoaded", function () { 1008 flatpickr("#@textField.Id", { 1009 @string.Join(",", jsAttributes) 1010 }); 1011 }); 1012 </script> 1013 } 1014 @using System.Reflection 1015 @using Dynamicweb.Rapido.Blocks.Components.General 1016 @using Dynamicweb.Rapido.Blocks.Components 1017 1018 @* Component *@ 1019 1020 @helper RenderTextField(TextField settings) 1021 { 1022 var attributes = new Dictionary<string, string>(); 1023 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1024 { 1025 settings.Id = Guid.NewGuid().ToString("N"); 1026 } 1027 1028 /*base settings*/ 1029 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1030 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1031 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1032 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1033 if (settings.Required) { attributes.Add("required", "true"); } 1034 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1035 /*end*/ 1036 1037 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1038 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1039 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1040 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1041 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1042 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1043 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1044 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1045 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1046 settings.CssClass = "u-full-width " + settings.CssClass; 1047 1048 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1049 1050 string noMargin = "u-no-margin"; 1051 if (!settings.ReadOnly) { 1052 noMargin = ""; 1053 } 1054 1055 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1056 @if (!string.IsNullOrEmpty(settings.Label)) 1057 { 1058 <label for="@settings.Id">@settings.Label</label> 1059 } 1060 @if (!string.IsNullOrEmpty(settings.HelpText)) 1061 { 1062 <small class="form__help-text">@settings.HelpText</small> 1063 } 1064 1065 @if (settings.ActionButton != null) 1066 { 1067 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1068 <div class="form__field-combi u-no-margin dw-mod"> 1069 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1070 @Render(settings.ActionButton) 1071 </div> 1072 } 1073 else 1074 { 1075 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1076 } 1077 1078 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1079 </div> 1080 } 1081 @using System.Reflection 1082 @using Dynamicweb.Rapido.Blocks.Components.General 1083 @using Dynamicweb.Rapido.Blocks.Components 1084 1085 @* Component *@ 1086 1087 @helper RenderNumberField(NumberField settings) 1088 { 1089 var attributes = new Dictionary<string, string>(); 1090 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1091 { 1092 settings.Id = Guid.NewGuid().ToString("N"); 1093 } 1094 1095 /*base settings*/ 1096 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1097 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1098 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1099 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1100 if (settings.Required) { attributes.Add("required", "true"); } 1101 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1102 /*end*/ 1103 1104 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1105 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1106 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1107 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1108 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1109 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1110 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1111 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1112 attributes.Add("type", "number"); 1113 1114 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1115 1116 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1117 @if (!string.IsNullOrEmpty(settings.Label)) 1118 { 1119 <label for="@settings.Id">@settings.Label</label> 1120 } 1121 @if (!string.IsNullOrEmpty(settings.HelpText)) 1122 { 1123 <small class="form__help-text">@settings.HelpText</small> 1124 } 1125 1126 @if (settings.ActionButton != null) 1127 { 1128 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1129 <div class="form__field-combi u-no-margin dw-mod"> 1130 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1131 @Render(settings.ActionButton) 1132 </div> 1133 } 1134 else 1135 { 1136 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1137 } 1138 1139 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1140 </div> 1141 } 1142 @using System.Reflection 1143 @using Dynamicweb.Rapido.Blocks.Components.General 1144 @using Dynamicweb.Rapido.Blocks.Components 1145 1146 1147 @* Component *@ 1148 1149 @helper RenderTextareaField(TextareaField settings) 1150 { 1151 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1152 string id = settings.Id; 1153 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1154 { 1155 id = Guid.NewGuid().ToString("N"); 1156 } 1157 1158 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1159 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1160 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1161 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1162 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1163 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1164 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1165 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1166 if (settings.Required) { attributes.Add("required", "true"); } 1167 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1168 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1169 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1170 attributes.Add("name", settings.Name); 1171 1172 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1173 @if (!string.IsNullOrEmpty(settings.Label)) 1174 { 1175 <label for="@id">@settings.Label</label> 1176 } 1177 @if (!string.IsNullOrEmpty(settings.HelpText)) 1178 { 1179 <small class="form__help-text">@settings.HelpText</small> 1180 } 1181 1182 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1183 1184 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1185 </div> 1186 } 1187 @using System.Reflection 1188 @using Dynamicweb.Rapido.Blocks.Components.General 1189 @using Dynamicweb.Rapido.Blocks.Components 1190 1191 1192 @* Component *@ 1193 1194 @helper RenderHiddenField(HiddenField settings) { 1195 var attributes = new Dictionary<string, string>(); 1196 attributes.Add("type", "hidden"); 1197 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1198 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1199 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1200 1201 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1202 } 1203 @using System.Reflection 1204 @using Dynamicweb.Rapido.Blocks.Components.General 1205 @using Dynamicweb.Rapido.Blocks.Components 1206 1207 @* Component *@ 1208 1209 @helper RenderCheckboxField(CheckboxField settings) 1210 { 1211 var attributes = new Dictionary<string, string>(); 1212 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1213 { 1214 settings.Id = Guid.NewGuid().ToString("N"); 1215 } 1216 1217 /*base settings*/ 1218 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1219 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1220 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1221 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1222 if (settings.Required) { attributes.Add("required", "true"); } 1223 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1224 /*end*/ 1225 1226 attributes.Add("type", "checkbox"); 1227 if (settings.Checked) { attributes.Add("checked", "true"); } 1228 settings.CssClass = "form__control " + settings.CssClass; 1229 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1230 1231 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1232 1233 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1234 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1235 @if (!string.IsNullOrEmpty(settings.Label)) 1236 { 1237 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1238 } 1239 @if (!string.IsNullOrEmpty(settings.HelpText)) 1240 { 1241 <small class="form__help-text">@settings.HelpText</small> 1242 } 1243 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1244 </div> 1245 } 1246 @using System.Reflection 1247 @using Dynamicweb.Rapido.Blocks.Components.General 1248 @using Dynamicweb.Rapido.Blocks.Components 1249 1250 1251 @* Component *@ 1252 1253 @helper RenderCheckboxListField(CheckboxListField settings) 1254 { 1255 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1256 @if (!string.IsNullOrEmpty(settings.Label)) 1257 { 1258 <label>@settings.Label</label> 1259 } 1260 @if (!string.IsNullOrEmpty(settings.HelpText)) 1261 { 1262 <small class="form__help-text">@settings.HelpText</small> 1263 } 1264 1265 @foreach (var item in settings.Options) 1266 { 1267 if (settings.Required) 1268 { 1269 item.Required = true; 1270 } 1271 if (settings.Disabled) 1272 { 1273 item.Disabled = true; 1274 } 1275 if (!string.IsNullOrEmpty(settings.Name)) 1276 { 1277 item.Name = settings.Name; 1278 } 1279 if (!string.IsNullOrEmpty(settings.CssClass)) 1280 { 1281 item.CssClass += settings.CssClass; 1282 } 1283 1284 /* value is not supported */ 1285 1286 if (!string.IsNullOrEmpty(settings.OnClick)) 1287 { 1288 item.OnClick += settings.OnClick; 1289 } 1290 if (!string.IsNullOrEmpty(settings.OnChange)) 1291 { 1292 item.OnChange += settings.OnChange; 1293 } 1294 @Render(item) 1295 } 1296 1297 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1298 </div> 1299 } 1300 @using System.Reflection 1301 @using Dynamicweb.Rapido.Blocks.Components.General 1302 @using Dynamicweb.Rapido.Blocks.Components 1303 1304 1305 @* Component *@ 1306 1307 @helper RenderSelectField(SelectField settings) 1308 { 1309 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1310 { 1311 settings.Id = Guid.NewGuid().ToString("N"); 1312 } 1313 1314 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1315 @if (!string.IsNullOrEmpty(settings.Label)) 1316 { 1317 <label for="@settings.Id">@settings.Label</label> 1318 } 1319 @if (!string.IsNullOrEmpty(settings.HelpText)) 1320 { 1321 <small class="form__help-text">@settings.HelpText</small> 1322 } 1323 1324 @if (settings.ActionButton != null) 1325 { 1326 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1327 <div class="form__field-combi u-no-margin dw-mod"> 1328 @RenderSelectBase(settings) 1329 @Render(settings.ActionButton) 1330 </div> 1331 } 1332 else 1333 { 1334 @RenderSelectBase(settings) 1335 } 1336 1337 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1338 </div> 1339 } 1340 1341 @helper RenderSelectBase(SelectField settings) 1342 { 1343 var attributes = new Dictionary<string, string>(); 1344 1345 /*base settings*/ 1346 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1347 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1348 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1349 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1350 if (settings.Required) { attributes.Add("required", "true"); } 1351 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1352 /*end*/ 1353 1354 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1355 1356 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1357 @if (settings.Default != null) 1358 { 1359 @Render(settings.Default) 1360 } 1361 1362 @foreach (var item in settings.Options) 1363 { 1364 if (!string.IsNullOrEmpty(settings.Value)) { 1365 item.Checked = item.Value == settings.Value; 1366 } 1367 @Render(item) 1368 } 1369 </select> 1370 } 1371 @using System.Reflection 1372 @using Dynamicweb.Rapido.Blocks.Components.General 1373 @using Dynamicweb.Rapido.Blocks.Components 1374 1375 @* Component *@ 1376 1377 @helper RenderRadioButtonField(RadioButtonField settings) 1378 { 1379 var attributes = new Dictionary<string, string>(); 1380 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1381 { 1382 settings.Id = Guid.NewGuid().ToString("N"); 1383 } 1384 1385 /*base settings*/ 1386 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1387 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1388 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1389 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1390 if (settings.Required) { attributes.Add("required", "true"); } 1391 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1392 /*end*/ 1393 1394 attributes.Add("type", "radio"); 1395 if (settings.Checked) { attributes.Add("checked", "true"); } 1396 settings.CssClass = "form__control " + settings.CssClass; 1397 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1398 1399 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1400 1401 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1402 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1403 @if (!string.IsNullOrEmpty(settings.Label)) 1404 { 1405 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1406 } 1407 @if (!string.IsNullOrEmpty(settings.HelpText)) 1408 { 1409 <small class="form__help-text">@settings.HelpText</small> 1410 } 1411 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1412 </div> 1413 } 1414 @using System.Reflection 1415 @using Dynamicweb.Rapido.Blocks.Components.General 1416 @using Dynamicweb.Rapido.Blocks.Components 1417 1418 1419 @* Component *@ 1420 1421 @helper RenderRadioButtonListField(RadioButtonListField settings) 1422 { 1423 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1424 @if (!string.IsNullOrEmpty(settings.Label)) 1425 { 1426 <label>@settings.Label</label> 1427 } 1428 @if (!string.IsNullOrEmpty(settings.HelpText)) 1429 { 1430 <small class="form__help-text">@settings.HelpText</small> 1431 } 1432 1433 @foreach (var item in settings.Options) 1434 { 1435 if (settings.Required) 1436 { 1437 item.Required = true; 1438 } 1439 if (settings.Disabled) 1440 { 1441 item.Disabled = true; 1442 } 1443 if (!string.IsNullOrEmpty(settings.Name)) 1444 { 1445 item.Name = settings.Name; 1446 } 1447 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1448 { 1449 item.Checked = true; 1450 } 1451 if (!string.IsNullOrEmpty(settings.OnClick)) 1452 { 1453 item.OnClick += settings.OnClick; 1454 } 1455 if (!string.IsNullOrEmpty(settings.OnChange)) 1456 { 1457 item.OnChange += settings.OnChange; 1458 } 1459 if (!string.IsNullOrEmpty(settings.CssClass)) 1460 { 1461 item.CssClass += settings.CssClass; 1462 } 1463 @Render(item) 1464 } 1465 1466 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1467 </div> 1468 } 1469 @using System.Reflection 1470 @using Dynamicweb.Rapido.Blocks.Components.General 1471 @using Dynamicweb.Rapido.Blocks.Components 1472 1473 1474 @* Component *@ 1475 1476 @helper RenderNotificationMessage(NotificationMessage settings) 1477 { 1478 if (!string.IsNullOrEmpty(settings.Message)) 1479 { 1480 var attributes = new Dictionary<string, string>(); 1481 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1482 1483 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1484 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1485 } 1486 } 1487 @using Dynamicweb.Rapido.Blocks.Components.General 1488 1489 1490 @* Component *@ 1491 1492 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1493 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1494 1495 <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> 1496 @if (settings.SubBlocks != null) { 1497 @RenderBlockList(settings.SubBlocks) 1498 } 1499 </div> 1500 } 1501 @using System.Reflection 1502 @using Dynamicweb.Rapido.Blocks.Components.General 1503 @using Dynamicweb.Rapido.Blocks.Components 1504 @using System.Text.RegularExpressions 1505 1506 1507 @* Component *@ 1508 1509 @helper RenderSticker(Sticker settings) { 1510 if (!String.IsNullOrEmpty(settings.Title)) { 1511 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1512 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1513 1514 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1515 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1516 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1517 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1518 optionalAttributes.Add("style", styleTag); 1519 } 1520 1521 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1522 } 1523 } 1524 1525 @using System.Reflection 1526 @using Dynamicweb.Rapido.Blocks.Components.General 1527 @using Dynamicweb.Rapido.Blocks.Components 1528 1529 1530 @* Component *@ 1531 1532 @helper RenderStickersCollection(StickersCollection settings) 1533 { 1534 if (settings.Stickers.Count > 0) 1535 { 1536 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1537 1538 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1539 @foreach (Sticker sticker in settings.Stickers) 1540 { 1541 @Render(sticker) 1542 } 1543 </div> 1544 } 1545 } 1546 1547 @using Dynamicweb.Rapido.Blocks.Components.General 1548 1549 1550 @* Component *@ 1551 1552 @helper RenderForm(Form settings) { 1553 if (settings != null) 1554 { 1555 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1556 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1557 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1558 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1559 var enctypes = new Dictionary<string, string> 1560 { 1561 { "multipart", "multipart/form-data" }, 1562 { "text", "text/plain" }, 1563 { "application", "application/x-www-form-urlencoded" } 1564 }; 1565 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1566 optionalAttributes.Add("method", settings.Method.ToString()); 1567 1568 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1569 { 1570 @settings.FormStartMarkup 1571 } 1572 else 1573 { 1574 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1575 } 1576 1577 foreach (var field in settings.GetFields()) 1578 { 1579 @Render(field) 1580 } 1581 1582 @:</form> 1583 } 1584 } 1585 @using System.Reflection 1586 @using Dynamicweb.Rapido.Blocks.Components.General 1587 @using Dynamicweb.Rapido.Blocks.Components 1588 1589 1590 @* Component *@ 1591 1592 @helper RenderText(Text settings) 1593 { 1594 @settings.Content 1595 } 1596 @using System.Reflection 1597 @using Dynamicweb.Rapido.Blocks.Components.General 1598 @using Dynamicweb.Rapido.Blocks.Components 1599 1600 1601 @* Component *@ 1602 1603 @helper RenderContentModule(ContentModule settings) { 1604 if (!string.IsNullOrEmpty(settings.Content)) 1605 { 1606 @settings.Content 1607 } 1608 } 1609 @using System.Reflection 1610 @using Dynamicweb.Rapido.Blocks.Components.General 1611 @using Dynamicweb.Rapido.Blocks.Components 1612 1613 1614 @* Component *@ 1615 1616 @helper RenderModal(Modal settings) { 1617 if (settings != null) 1618 { 1619 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1620 1621 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1622 1623 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1624 1625 <div class="modal-container"> 1626 @if (!settings.DisableDarkOverlay) 1627 { 1628 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1629 } 1630 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1631 @if (settings.Heading != null) 1632 { 1633 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1634 { 1635 <div class="modal__header"> 1636 @Render(settings.Heading) 1637 </div> 1638 } 1639 } 1640 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1641 @if (!string.IsNullOrEmpty(settings.BodyText)) 1642 { 1643 @settings.BodyText 1644 } 1645 @if (settings.BodyTemplate != null) 1646 { 1647 @settings.BodyTemplate 1648 } 1649 @{ 1650 var actions = settings.GetActions(); 1651 } 1652 </div> 1653 @if (actions.Length > 0) 1654 { 1655 <div class="modal__footer"> 1656 @foreach (var action in actions) 1657 { 1658 action.CssClass += " u-no-margin"; 1659 @Render(action) 1660 } 1661 </div> 1662 } 1663 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1664 </div> 1665 </div> 1666 } 1667 } 1668 @using Dynamicweb.Rapido.Blocks.Components.General 1669 1670 @* Component *@ 1671 1672 @helper RenderMediaListItem(MediaListItem settings) 1673 { 1674 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1675 @if (!string.IsNullOrEmpty(settings.Label)) 1676 { 1677 if (!string.IsNullOrEmpty(settings.Link)) 1678 { 1679 @Render(new Link 1680 { 1681 Href = settings.Link, 1682 CssClass = "media-list-item__sticker dw-mod", 1683 ButtonLayout = ButtonLayout.None, 1684 Title = settings.Label, 1685 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1686 }) 1687 } 1688 else if (!string.IsNullOrEmpty(settings.OnClick)) 1689 { 1690 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1691 <span class="u-uppercase">@settings.Label</span> 1692 </span> 1693 } 1694 else 1695 { 1696 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1697 <span class="u-uppercase">@settings.Label</span> 1698 </span> 1699 } 1700 } 1701 <div class="media-list-item__wrap"> 1702 <div class="media-list-item__info dw-mod"> 1703 <div class="media-list-item__header dw-mod"> 1704 @if (!string.IsNullOrEmpty(settings.Title)) 1705 { 1706 if (!string.IsNullOrEmpty(settings.Link)) 1707 { 1708 @Render(new Link 1709 { 1710 Href = settings.Link, 1711 CssClass = "media-list-item__name dw-mod", 1712 ButtonLayout = ButtonLayout.None, 1713 Title = settings.Title, 1714 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1715 }) 1716 } 1717 else if (!string.IsNullOrEmpty(settings.OnClick)) 1718 { 1719 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1720 } 1721 else 1722 { 1723 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1724 } 1725 } 1726 1727 @if (!string.IsNullOrEmpty(settings.Status)) 1728 { 1729 <div class="media-list-item__state dw-mod">@settings.Status</div> 1730 } 1731 </div> 1732 @{ 1733 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1734 } 1735 1736 @Render(settings.InfoTable) 1737 </div> 1738 <div class="media-list-item__actions dw-mod"> 1739 <div class="media-list-item__actions-list dw-mod"> 1740 @{ 1741 var actions = settings.GetActions(); 1742 1743 foreach (ButtonBase action in actions) 1744 { 1745 action.ButtonLayout = ButtonLayout.None; 1746 action.CssClass += " media-list-item__action link"; 1747 1748 @Render(action) 1749 } 1750 } 1751 </div> 1752 1753 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1754 { 1755 settings.SelectButton.CssClass += " u-no-margin"; 1756 1757 <div class="media-list-item__action-button"> 1758 @Render(settings.SelectButton) 1759 </div> 1760 } 1761 </div> 1762 </div> 1763 </div> 1764 } 1765 @using Dynamicweb.Rapido.Blocks.Components.General 1766 @using Dynamicweb.Rapido.Blocks.Components 1767 1768 @helper RenderTable(Table settings) 1769 { 1770 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1771 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1772 1773 var enumToClasses = new Dictionary<TableDesign, string> 1774 { 1775 { TableDesign.Clean, "table--clean" }, 1776 { TableDesign.Bordered, "table--bordered" }, 1777 { TableDesign.Striped, "table--striped" }, 1778 { TableDesign.Hover, "table--hover" }, 1779 { TableDesign.Compact, "table--compact" }, 1780 { TableDesign.Condensed, "table--condensed" }, 1781 { TableDesign.NoTopBorder, "table--no-top-border" } 1782 }; 1783 string tableDesignClass = ""; 1784 if (settings.Design != TableDesign.None) 1785 { 1786 tableDesignClass = enumToClasses[settings.Design]; 1787 } 1788 1789 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1790 1791 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1792 1793 <table @ComponentMethods.AddAttributes(resultAttributes)> 1794 @if (settings.Header != null) 1795 { 1796 <thead> 1797 @Render(settings.Header) 1798 </thead> 1799 } 1800 <tbody> 1801 @foreach (var row in settings.Rows) 1802 { 1803 @Render(row) 1804 } 1805 </tbody> 1806 @if (settings.Footer != null) 1807 { 1808 <tfoot> 1809 @Render(settings.Footer) 1810 </tfoot> 1811 } 1812 </table> 1813 } 1814 @using Dynamicweb.Rapido.Blocks.Components.General 1815 @using Dynamicweb.Rapido.Blocks.Components 1816 1817 @helper RenderTableRow(TableRow settings) 1818 { 1819 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1820 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1821 1822 var enumToClasses = new Dictionary<TableRowDesign, string> 1823 { 1824 { TableRowDesign.NoBorder, "table__row--no-border" }, 1825 { TableRowDesign.Border, "table__row--border" }, 1826 { TableRowDesign.TopBorder, "table__row--top-line" }, 1827 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1828 { TableRowDesign.Solid, "table__row--solid" } 1829 }; 1830 1831 string tableRowDesignClass = ""; 1832 if (settings.Design != TableRowDesign.None) 1833 { 1834 tableRowDesignClass = enumToClasses[settings.Design]; 1835 } 1836 1837 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1838 1839 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1840 1841 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1842 @foreach (var cell in settings.Cells) 1843 { 1844 if (settings.IsHeaderRow) 1845 { 1846 cell.IsHeader = true; 1847 } 1848 @Render(cell) 1849 } 1850 </tr> 1851 } 1852 @using Dynamicweb.Rapido.Blocks.Components.General 1853 @using Dynamicweb.Rapido.Blocks.Components 1854 @using Dynamicweb.Core 1855 1856 @helper RenderTableCell(TableCell settings) 1857 { 1858 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1859 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1860 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1861 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1862 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1863 1864 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1865 1866 string tagName = settings.IsHeader ? "th" : "td"; 1867 1868 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 1869 @settings.Content 1870 @("</" + tagName + ">"); 1871 } 1872 @using System.Linq 1873 @using Dynamicweb.Rapido.Blocks.Components.General 1874 1875 @* Component *@ 1876 1877 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1878 { 1879 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1880 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1881 1882 if (settings.NumberOfPages > 1) 1883 { 1884 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1885 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 1886 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1887 1888 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1889 @if (settings.ShowPagingInfo) 1890 { 1891 <div class="pager__info dw-mod"> 1892 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1893 </div> 1894 } 1895 <ul class="pager__list dw-mod"> 1896 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1897 { 1898 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1899 } 1900 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1901 { 1902 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 1903 } 1904 @if (settings.GetPages().Any()) 1905 { 1906 foreach (var page in settings.GetPages()) 1907 { 1908 @Render(page) 1909 } 1910 } 1911 else 1912 { 1913 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1914 { 1915 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1916 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1917 } 1918 } 1919 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1920 { 1921 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 1922 } 1923 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1924 { 1925 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1926 } 1927 </ul> 1928 </div> 1929 } 1930 } 1931 1932 @helper RenderPaginationItem(PaginationItem settings) 1933 { 1934 if (settings.Icon == null) 1935 { 1936 settings.Icon = new Icon(); 1937 } 1938 1939 settings.Icon.Label = settings.Label; 1940 <li class="pager__btn dw-mod"> 1941 @if (settings.IsActive) 1942 { 1943 <span class="pager__num pager__num--current dw-mod"> 1944 @Render(settings.Icon) 1945 </span> 1946 } 1947 else 1948 { 1949 <a href="@settings.Link" class="pager__num dw-mod"> 1950 @Render(settings.Icon) 1951 </a> 1952 } 1953 </li> 1954 } 1955 1956 1957 @using Dynamicweb.Rapido.Blocks.Components.General 1958 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 1959 1960 1961 @using Dynamicweb.Rapido.Blocks.Components 1962 @using Dynamicweb.Rapido.Blocks.Components.General 1963 @using Dynamicweb.Rapido.Blocks 1964 @using System.IO 1965 1966 1967 @using Dynamicweb.Rapido.Blocks.Components.General 1968 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 1969 1970 1971 @* Component *@ 1972 1973 @helper RenderVariantMatrix(VariantMatrix settings) { 1974 if (settings != null) 1975 { 1976 int productLoopCounter = 0; 1977 int groupCount = 0; 1978 List<VariantOption> firstDimension = new List<VariantOption>(); 1979 List<VariantOption> secondDimension = new List<VariantOption>(); 1980 List<VariantOption> thirdDimension = new List<VariantOption>(); 1981 1982 foreach (VariantGroup variantGroup in settings.GetVariantGroups()) 1983 { 1984 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions()) 1985 { 1986 if (groupCount == 0) { 1987 firstDimension.Add(variantOptions); 1988 } 1989 if (groupCount == 1) 1990 { 1991 secondDimension.Add(variantOptions); 1992 } 1993 if (groupCount == 2) 1994 { 1995 thirdDimension.Add(variantOptions); 1996 } 1997 } 1998 groupCount++; 1999 } 2000 2001 int rowCount = 0; 2002 int columnCount = 0; 2003 2004 <script> 2005 var variantsCollection = []; 2006 </script> 2007 2008 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId"> 2009 @if (groupCount == 1) 2010 { 2011 <tbody> 2012 @foreach (VariantOption firstVariantOption in firstDimension) 2013 { 2014 var variantId = firstVariantOption.Id; 2015 <tr> 2016 <td class="u-bold"> 2017 @firstVariantOption.Name 2018 </td> 2019 <td> 2020 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2021 </td> 2022 </tr> 2023 productLoopCounter++; 2024 } 2025 2026 <tr> 2027 <td>&nbsp;</td> 2028 <td> 2029 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2030 </td> 2031 </tr> 2032 </tbody> 2033 } 2034 @if (groupCount == 2) 2035 { 2036 <thead> 2037 <tr> 2038 <td>&nbsp;</td> 2039 @foreach (VariantOption variant in secondDimension) 2040 { 2041 <td>@variant.Name</td> 2042 } 2043 </tr> 2044 </thead> 2045 <tbody> 2046 @foreach (VariantOption firstVariantOption in firstDimension) 2047 { 2048 string variantId = ""; 2049 columnCount = 0; 2050 2051 <tr> 2052 <td class="u-min-w120px">@firstVariantOption.Name</td> 2053 2054 @foreach (VariantOption secondVariantOption in secondDimension) 2055 { 2056 variantId = firstVariantOption.Id + "." + secondVariantOption.Id; 2057 <td> 2058 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2059 </td> 2060 2061 columnCount++; 2062 2063 productLoopCounter++; 2064 } 2065 2066 <td> 2067 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 2068 </td> 2069 </tr> 2070 2071 rowCount++; 2072 } 2073 2074 @{ 2075 columnCount = 0; 2076 } 2077 2078 <tr> 2079 <td>&nbsp;</td> 2080 @foreach (VariantOption secondVariantOption in secondDimension) 2081 { 2082 <td> 2083 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2084 </td> 2085 2086 columnCount++; 2087 } 2088 <td>&nbsp;</td> 2089 </tr> 2090 </tbody> 2091 } 2092 @if (groupCount == 3) 2093 { 2094 <thead> 2095 <tr> 2096 <td>&nbsp;</td> 2097 @foreach (VariantOption thirdVariantOption in thirdDimension) 2098 { 2099 <td>@thirdVariantOption.Name</td> 2100 } 2101 </tr> 2102 </thead> 2103 <tbody> 2104 @foreach (VariantOption firstVariantOption in firstDimension) 2105 { 2106 int colspan = (thirdDimension.Count + 1); 2107 2108 <tr> 2109 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td> 2110 </tr> 2111 2112 foreach (VariantOption secondVariantOption in secondDimension) 2113 { 2114 string variantId = ""; 2115 columnCount = 0; 2116 2117 <tr> 2118 <td class="u-min-w120px">@secondVariantOption.Name</td> 2119 2120 @foreach (VariantOption thirdVariantOption in thirdDimension) 2121 { 2122 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id; 2123 2124 <td> 2125 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2126 </td> 2127 2128 columnCount++; 2129 productLoopCounter++; 2130 } 2131 2132 <td> 2133 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 2134 </td> 2135 </tr> 2136 rowCount++; 2137 } 2138 } 2139 2140 @{ 2141 columnCount = 0; 2142 } 2143 2144 <tr> 2145 <td>&nbsp;</td> 2146 @foreach (VariantOption thirdVariantOption in thirdDimension) 2147 { 2148 <td> 2149 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2150 </td> 2151 2152 columnCount++; 2153 } 2154 <td>&nbsp;</td> 2155 </tr> 2156 </tbody> 2157 } 2158 </table> 2159 2160 <script> 2161 document.addEventListener("DOMContentLoaded", function (event) { 2162 MatrixUpdateQuantity("@settings.ProductId"); 2163 }); 2164 2165 MatrixUpdateQuantity = function (productId) { 2166 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId); 2167 var allQtyFields = currentMatrix.getElementsByClassName("js-qty"); 2168 2169 var qtyRowArr = []; 2170 var qtyColumnArr = []; 2171 2172 var totalQty = 0; 2173 2174 for (var i = 0; i < allQtyFields.length; i++) { 2175 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0; 2176 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0; 2177 } 2178 2179 for (var i = 0; i < allQtyFields.length; i++) { 2180 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value); 2181 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value); 2182 totalQty += parseFloat(allQtyFields[i].value); 2183 } 2184 2185 //Update row counters 2186 for (var i = 0; i < qtyRowArr.length; i++) { 2187 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 2188 2189 if (qtyRowArr[i] != undefined && qtyCounter != null) { 2190 var currentCount = qtyCounter.innerHTML; 2191 qtyCounter.innerHTML = qtyRowArr[i]; 2192 2193 if (currentCount != qtyCounter.innerHTML) { 2194 qtyCounter.classList.add("qty-field--active"); 2195 } 2196 } 2197 2198 } 2199 2200 //Update column counters 2201 for (var i = 0; i < qtyColumnArr.length; i++) { 2202 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 2203 2204 if (qtyColumnArr[i] != undefined && qtyCounter != null) { 2205 var currentCount = qtyCounter.innerHTML; 2206 qtyCounter.innerHTML = qtyColumnArr[i]; 2207 2208 if (currentCount != qtyCounter.innerHTML) { 2209 qtyCounter.classList.add("qty-field--active"); 2210 } 2211 } 2212 } 2213 2214 if (document.getElementById("TotalQtyCount_" + productId)) { 2215 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty; 2216 } 2217 2218 //Clean up animations 2219 setTimeout(function () { 2220 for (var i = 0; i < qtyRowArr.length; i++) { 2221 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 2222 if (qtyCounter != null) { 2223 qtyCounter.classList.remove("qty-field--active"); 2224 } 2225 } 2226 for (var i = 0; i < qtyColumnArr.length; i++) { 2227 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 2228 if (qtyCounter != null) { 2229 qtyCounter.classList.remove("qty-field--active"); 2230 } 2231 } 2232 }, 1000); 2233 } 2234 </script> 2235 } 2236 } 2237 2238 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount) 2239 { 2240 string loopCount = productLoopCounter.ToString(); 2241 2242 bool combinationFound = false; 2243 double stock = 0; 2244 double quantityValue = 0; 2245 string note = ""; 2246 2247 VariantProduct variantProduct = null; 2248 2249 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct)) 2250 { 2251 stock = variantProduct.Stock; 2252 quantityValue = variantProduct.Quantity; 2253 combinationFound = true; 2254 } 2255 2256 if (combinationFound) 2257 { 2258 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" /> 2259 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" /> 2260 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" /> 2261 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" /> 2262 <input type="number" name="Quantity@(loopCount)" id="Quantity_@(settings.ProductId)_@variantId" value="@quantityValue" min="0" class="js-qty u-no-margin u-full-max-width" style="width: 100%; max-width: 100%" onkeyup="MatrixUpdateQuantity('@settings.ProductId')" onmouseup="MatrixUpdateQuantity('@settings.ProductId')" data-qty-row-group="@rowCount" data-qty-column-group="@columnCount"> 2263 2264 if (stock != 0) 2265 { 2266 <small>@Translate("Stock") @stock</small> 2267 } 2268 2269 <script> 2270 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}'; 2271 variantsCollection.push(variants); 2272 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" ); 2273 </script> 2274 } 2275 else 2276 { 2277 <div class="use-btn-height" style="background-color: #a8a8a8"></div> 2278 } 2279 } 2280 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2281 2282 @* Component *@ 2283 2284 @helper RenderAddToCart(AddToCart settings) 2285 { 2286 //set Id for quantity selector to get it's value from button 2287 if (settings.QuantitySelector != null) 2288 { 2289 if (string.IsNullOrEmpty(settings.QuantitySelector.Id)) 2290 { 2291 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N"); 2292 } 2293 2294 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id; 2295 2296 if (settings.Disabled) 2297 { 2298 settings.QuantitySelector.Disabled = true; 2299 } 2300 2301 if (string.IsNullOrEmpty(settings.QuantitySelector.Name)) 2302 { 2303 settings.QuantitySelector.Name = settings.QuantitySelector.Id; 2304 } 2305 } 2306 2307 if (settings.Disabled) 2308 { 2309 settings.AddButton.Disabled = true; 2310 } 2311 2312 settings.AddButton.CssClass += " btn--condensed"; 2313 2314 //unitsSelector 2315 if (settings.UnitSelector != null) 2316 { 2317 if (settings.Disabled) 2318 { 2319 settings.QuantitySelector.Disabled = true; 2320 } 2321 } 2322 2323 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2324 @if (settings.UnitSelector != null) 2325 { 2326 @Render(settings.UnitSelector) 2327 } 2328 @if (settings.QuantitySelector != null) 2329 { 2330 @Render(settings.QuantitySelector) 2331 } 2332 @Render(settings.AddButton) 2333 </div> 2334 } 2335 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2336 2337 @* Component *@ 2338 2339 @helper RenderAddToCartButton(AddToCartButton settings) 2340 { 2341 if (!settings.HideTitle) 2342 { 2343 if (string.IsNullOrEmpty(settings.Title)) 2344 { 2345 if (settings.BuyForPoints) 2346 { 2347 settings.Title = Translate("Buy with points"); 2348 } 2349 else 2350 { 2351 settings.Title = Translate("Add to cart"); 2352 } 2353 } 2354 } 2355 else 2356 { 2357 settings.Title = ""; 2358 } 2359 2360 if (settings.Icon == null) 2361 { 2362 settings.Icon = new Icon(); 2363 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After; 2364 } 2365 2366 if (string.IsNullOrEmpty(settings.Icon.Name)) 2367 { 2368 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue; 2369 } 2370 2371 settings.OnClick = "Cart.AddToCart(event, { " + 2372 "id: '" + settings.ProductId + "'," + 2373 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") + 2374 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") + 2375 (settings.BuyForPoints ? "buyForPoints: true," : "") + 2376 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") + 2377 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") + 2378 "});" + settings.OnClick; 2379 2380 @RenderButton(settings) 2381 } 2382 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2383 2384 @* Component *@ 2385 2386 @helper RenderUnitSelector(UnitSelector settings) 2387 { 2388 if (string.IsNullOrEmpty(settings.Id)) 2389 { 2390 settings.Id = Guid.NewGuid().ToString("N"); 2391 } 2392 var disabledClass = settings.Disabled ? "disabled" : ""; 2393 2394 <input type="checkbox" id="@settings.Id" class="dropdown-trigger" /> 2395 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2396 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@settings.Id">@settings.SelectedOption</label> 2397 <div class="dropdown__content dw-mod"> 2398 @settings.OptionsContent 2399 </div> 2400 <label class="dropdown-trigger-off" for="@settings.Id"></label> 2401 </div> 2402 } 2403 @using System.Reflection 2404 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2405 2406 @* Component *@ 2407 2408 @helper RenderQuantitySelector(QuantitySelector settings) 2409 { 2410 var attributes = new Dictionary<string, string>(); 2411 2412 /*base settings*/ 2413 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2414 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2415 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2416 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2417 if (settings.Required) { attributes.Add("required", "true"); } 2418 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2419 /*end*/ 2420 2421 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 2422 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 2423 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 2424 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 2425 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 2426 if (settings.Min == null) { settings.Min = 1; } 2427 attributes.Add("min", settings.Min.ToString()); 2428 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); } 2429 if (settings.Value == null) { settings.Value = 1; } 2430 attributes.Add("value", settings.Value.ToString()); 2431 attributes.Add("type", "number"); 2432 2433 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2434 2435 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2436 } 2437 2438 @* Include the Blocks for the page *@ 2439 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2440 @using Dynamicweb.Core 2441 @using System 2442 @using System.Web 2443 @using System.Collections.Generic 2444 @using Dynamicweb.Rapido.Blocks 2445 2446 @{ 2447 BlocksPage productListProductsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 2448 2449 Block productsBlock = new Block 2450 { 2451 Id = "Views", 2452 SortId = 30, 2453 Template = RenderProducts() 2454 }; 2455 2456 productListProductsBlocksPage.Add("ProductList", productsBlock); 2457 } 2458 2459 @helper RenderProducts() 2460 { 2461 @*This is part of a script template *@ 2462 2463 <div id="ProductsContainer" data-template="{{listTemplate}}" class="grid product-list grid--external-bleed-x dw-mod grid--align-content-start" data-save-cookie="true"> 2464 {{#ProductsContainer}} 2465 {{> (lookup . 'template') }} 2466 {{/ProductsContainer}} 2467 </div> 2468 } 2469 2470 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2471 @using Dynamicweb.Core 2472 @using System 2473 @using System.Web 2474 @using System.Collections.Generic 2475 @using Dynamicweb.Rapido.Blocks 2476 @using Dynamicweb.Rapido.Services 2477 2478 @functions { 2479 BlocksPage listViewPage = BlocksPage.GetBlockPage("ProductList"); 2480 Dynamicweb.Frontend.ItemViewModel listViewSettings = null; 2481 } 2482 2483 @if (Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableListView")) 2484 { 2485 listViewSettings = Pageview.AreaSettings.GetItem("ProductList").GetItem("ListView"); 2486 2487 listViewPage.Add("Views", new Block 2488 { 2489 Id = "ProductItemContainer", 2490 Name = "th-list", 2491 SortId = 10 2492 }); 2493 2494 Block listViewScripts = new Block 2495 { 2496 Id = "ListViewScripts", 2497 SortId = 20, 2498 Template = ListView(), 2499 BlocksList = new List<Block> { 2500 new Block 2501 { 2502 Id = "ListViewItem", 2503 SortId = 10, 2504 Template = RenderListViewItem(), 2505 SkipRenderBlocksList = true, 2506 BlocksList = new List<Block> { 2507 new Block 2508 { 2509 Id = "ListViewItemHiddenProperties", 2510 SortId = 10, 2511 Template = RenderListViewItemHiddenProperties() 2512 }, 2513 new Block 2514 { 2515 Id = "ListViewItemLeft", 2516 SortId = 10, 2517 SkipRenderBlocksList = true, 2518 Template = RenderListViewItemLeft(), 2519 BlocksList = new List<Block> { 2520 new Block 2521 { 2522 Id = "ListViewItemImage", 2523 SortId = 10, 2524 Template = RenderListViewItemImage() 2525 }, 2526 new Block 2527 { 2528 Id = "ListViewItemStickers", 2529 SortId = 20, 2530 Template = RenderListViewItemStickers() 2531 } 2532 } 2533 }, 2534 new Block 2535 { 2536 Id = "ListViewItemRight", 2537 SortId = 20, 2538 Design = new Design 2539 { 2540 RenderType = RenderType.Column, 2541 Size = "auto", 2542 CssClass = "product-list__list-item__right" 2543 }, 2544 BlocksList = new List<Block> { 2545 new Block 2546 { 2547 Id = "ListViewItemInfoContainer", 2548 SortId = 10, 2549 Design = new Design 2550 { 2551 RenderType = RenderType.None 2552 }, 2553 BlocksList = new List<Block> { 2554 new Block { 2555 Id = "ListViewItemInfoContainerLeft", 2556 SortId = 10, 2557 Design = new Design 2558 { 2559 CssClass = "u-pull--left" 2560 }, 2561 BlocksList = new List<Block> { 2562 new Block 2563 { 2564 Id = "ListViewItemTitle", 2565 SortId = 10, 2566 Template = RenderListViewItemTitle() 2567 } 2568 } 2569 }, 2570 new Block { 2571 Id = "ListViewItemInfoContainerRight", 2572 SortId = 20, 2573 Design = new Design 2574 { 2575 CssClass = "u-pull--right" 2576 } 2577 } 2578 } 2579 }, 2580 new Block 2581 { 2582 Id = "ListViewItemDescription", 2583 SortId = 20, 2584 Template = RenderListViewItemDescription() 2585 }, 2586 new Block 2587 { 2588 Id = "ListViewItemFooter", 2589 SortId = 50, 2590 SkipRenderBlocksList = true, 2591 Template = RenderListViewItemFooter(), 2592 BlocksList = new List<Block> { 2593 new Block 2594 { 2595 Id = "ListViewItemActions", 2596 SortId = 20, 2597 Template = RenderListViewItemActions() 2598 } 2599 } 2600 } 2601 } 2602 } 2603 } 2604 } 2605 } 2606 }; 2607 listViewPage.Add("BottomSnippets", listViewScripts); 2608 2609 //number 2610 bool listViewShowNumber = listViewSettings.GetBoolean("ShowProductNumber"); 2611 2612 if (listViewShowNumber) 2613 { 2614 listViewPage.Add("ListViewItemInfoContainerLeft", new Block 2615 { 2616 Id = "ListViewItemNumber", 2617 SortId = 20, 2618 Template = RenderListViewItemNumber() 2619 }); 2620 } 2621 2622 //stock 2623 bool listViewShowStock = listViewSettings.GetBoolean("ShowStockAndShipping"); 2624 if (User.IsStockInfoAllowed() && listViewShowStock) 2625 { 2626 listViewPage.Add("ListViewItemInfoContainerLeft", new Block 2627 { 2628 Id = "ListViewItemStock", 2629 SortId = 30, 2630 Template = RenderListViewItemStock() 2631 }); 2632 } 2633 2634 //favorites 2635 bool listViewShowFavoriteButton = !listViewSettings.GetBoolean("HideFavoriteButton"); 2636 2637 if (listViewShowFavoriteButton) 2638 { 2639 listViewPage.Add("ListViewItemInfoContainerRight", new Block 2640 { 2641 Id = "ListViewItemFavorites", 2642 SortId = 10, 2643 Template = RenderListViewItemFavorites() 2644 }); 2645 } 2646 2647 //variant selector 2648 bool listViewShowCartButton = listViewSettings.GetBoolean("ShowAddToCartButton"); 2649 bool listViewShowVariantSelector = listViewSettings.GetList("Variants").SelectedValue == "selector"; 2650 if (listViewShowCartButton && listViewShowVariantSelector) 2651 { 2652 listViewPage.Add("ListViewItemRight", new Block 2653 { 2654 Id = "ListViewItemVariantSelector", 2655 SortId = 30, 2656 Template = RenderListViewItemVariantSelector() 2657 }); 2658 } 2659 2660 //static variants 2661 bool listViewShowStaticVariants = listViewSettings.GetList("Variants").SelectedValue == "static"; 2662 2663 if (listViewShowStaticVariants) 2664 { 2665 listViewPage.Add("ListViewItemRight", new Block 2666 { 2667 Id = "ListViewItemStaticVariants", 2668 SortId = 40, 2669 Template = RenderListViewItemStaticVariants() 2670 }); 2671 } 2672 2673 //download button 2674 bool listViewShowAddToDownloadButton = listViewSettings.GetBoolean("ShowAddToDownloadButton"); 2675 if (listViewShowAddToDownloadButton && Pageview.User != null) 2676 { 2677 listViewPage.Add("ListViewItemRight", new Block 2678 { 2679 Id = "ListViewItemDownloadButton", 2680 SortId = 60, 2681 Template = RenderListViewItemDownloadButton() 2682 }); 2683 } 2684 2685 //price 2686 bool listViewShowPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 2687 if (listViewShowPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 2688 { 2689 listViewPage.Add("ListViewItemFooter", new Block 2690 { 2691 Id = "ListViewItemPrice", 2692 SortId = 10, 2693 Template = RenderListViewItemPrice() 2694 }); 2695 } 2696 } 2697 2698 @helper ListView() 2699 { 2700 <script id="ProductItemContainer" type="text/x-template"> 2701 {{#.}} 2702 <div id="Product{{id}}" class="grid__col-12 js-product dw-mod" data-template="ListViewItem" data-preloader="overlay"> 2703 {{#Product}} 2704 {{>ListViewItem}} 2705 {{/Product}} 2706 </div> 2707 {{/.}} 2708 </script> 2709 } 2710 2711 @helper RenderListViewItem() 2712 { 2713 List<Block> subBlocks = listViewPage.GetBlockListById("ListViewItem"); 2714 2715 <script id="ListViewItem" type="text/x-template"> 2716 {{#.}} 2717 <div class="grid product-list__list-item dw-mod js-product-scroll-trigger" data-params="{{googleImpression}}"> 2718 @RenderBlockList(subBlocks) 2719 </div> 2720 {{/.}} 2721 </script> 2722 } 2723 2724 @helper RenderListViewItemHiddenProperties() 2725 { 2726 <input type="hidden" name="ProductLoopCounter{{id}}" value="{{id}}" /> 2727 <input type="hidden" name="ProductID{{id}}" value="{{productId}}" /> 2728 <input type="hidden" name="VariantID{{id}}" value="{{variantid}}" id="Variant_{{id}}" /> 2729 <input type="hidden" name="UnitID{{id}}" value="{{unitId}}" id="Unit_{{id}}" /> 2730 } 2731 2732 @helper RenderListViewItemLeft() 2733 { 2734 List<Block> subBlocks = listViewPage.GetBlockListById("ListViewItemLeft"); 2735 2736 string imageZoomOnHover = listViewSettings.GetBoolean("HoverImageZoom") ? "image-hover--zoom" : ""; 2737 2738 <div class="grid__col-md-4 {{noImage}} product-list__list-item__left u-no-padding u-color-light--bg dw-mod @imageZoomOnHover"> 2739 <div class="grid__cell"> 2740 @RenderBlockList(subBlocks) 2741 </div> 2742 </div> 2743 } 2744 2745 @helper RenderListViewItemImage() 2746 { 2747 bool secondaryImage = listViewSettings.GetString("HoverAlternatineImage") != null ? listViewSettings.GetBoolean("HoverAlternatineImage") : false; 2748 2749 <a href="{{link}}" 2750 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" 2751 title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}" 2752 class="u-position-relative u-block image-hover__wrapper dw-mod"> 2753 <img class="grid__cell-img grid__cell-img--centered b-lazy" src="/Files/Images/placeholder.gif" 2754 data-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop=5&amp;Compression=75&amp;DoNotUpscale=true&amp;FillCanvas=true&amp;image={{image}}" 2755 @if (secondaryImage) { 2756 <text> 2757 {{#if secondaryImage}} 2758 data-secondary-image-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop=5&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{secondaryImage}}" 2759 {{/if}} 2760 </text> 2761 } 2762 alt="{{name}}{{#if variantName}}, {{variantName}}{{/if}}" /> 2763 </a> 2764 } 2765 2766 @helper RenderListViewItemStickers() 2767 { 2768 <text> 2769 {{#StickersContainers}} 2770 {{>StickersContainer}} 2771 {{/StickersContainers}} 2772 </text> 2773 } 2774 2775 @helper RenderListViewItemTitle() 2776 { 2777 <a href="{{link}}" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}"> 2778 <h2 class="u-no-margin">{{name}}{{#if variantName}}, {{variantName}}{{/if}}</h2> 2779 </a> 2780 } 2781 2782 @helper RenderListViewItemNumber() 2783 { 2784 <div class="item-number dw-mod">{{number}}</div> 2785 } 2786 2787 @helper RenderListViewItemStock() 2788 { 2789 <text>{{#if stockText}}</text> 2790 <div> 2791 <span class="stock-icon {{stockState}} u-no-margin dw-mod" title="{{stockText}}"></span> 2792 <span class="u-margin-right--lg"> {{stockText}}</span> 2793 {{deliveryText}} 2794 </div> 2795 <text>{{/if}}</text> 2796 } 2797 2798 @helper RenderListViewItemFavorites() 2799 { 2800 <div class="favorites u-pull--right {{hasVariants}} dw-mod" {{hasVariants}}> 2801 {{#Favorite}} 2802 {{>FavoriteTemplate}} 2803 {{/Favorite}} 2804 </div> 2805 } 2806 2807 @helper RenderListViewItemDescription() 2808 { 2809 <div class="grid__cell u-margin-top u-margin-bottom"> 2810 {{{description}}} 2811 </div> 2812 } 2813 2814 @helper RenderListViewItemVariantSelector() 2815 { 2816 string pageId = GetGlobalValue("Global:Page.ID"); 2817 var ecommerceSettings = Pageview.AreaSettings.GetItem("Ecommerce"); 2818 string variantsLayout = ecommerceSettings.GetString("VariantsLayout") != null ? ecommerceSettings.GetList("VariantsLayout").SelectedValue : "buttons"; 2819 2820 <div data-template="VariantsTemplate" class="js-variants grid__cell" data-combinations="{{combinationsStringArray}}" data-variants="{{variantsStringArray}}" data-variant-selections="{{variantSelections}}" data-total-variant-groups="{{variantGroupsCount}}" data-selection-complete="UpdateData" data-page-id="@pageId" data-product-id="{{productId}}"> 2821 {{#Variants}} 2822 @if (variantsLayout == "buttons") { 2823 <text>{{>VariantsTemplate}}</text> 2824 } else { 2825 <text>{{>DropdownVariantsTemplate}}</text> 2826 } 2827 {{/Variants}} 2828 </div> 2829 <small class="js-help-text help-text {{hideViewMore}} {{hideHelpText}}">@Translate("Please select variant!")</small> 2830 } 2831 2832 @helper RenderListViewItemStaticVariants() 2833 { 2834 <text> 2835 {{#Variants}} 2836 {{>StaticVariantsTemplate}} 2837 {{/Variants}} 2838 {{#ifCond variantGroupsCount '>' 1}} 2839 <div class="static-variant"> 2840 @Translate("More options available") 2841 </div> 2842 {{/ifCond}} 2843 </text> 2844 } 2845 2846 @helper RenderListViewItemFooter() 2847 { 2848 List<Block> subBlocks = listViewPage.GetBlockListById("ListViewItemFooter"); 2849 2850 if (Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 2851 { 2852 <div class="grid__cell-footer"> 2853 <div class="grid__cell"> 2854 <div class="product-list__list-item__price-actions dw-mod"> 2855 @RenderBlockList(subBlocks) 2856 </div> 2857 </div> 2858 </div> 2859 } 2860 else 2861 { 2862 <button type="button" id="CartButton_{{id}}" class="u-hidden"></button> 2863 } 2864 } 2865 2866 @helper RenderListViewItemPrice() 2867 { 2868 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 2869 bool showCartButton = listViewSettings.GetBoolean("ShowAddToCartButton"); 2870 bool showVATPrice = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("ShowBothPricesWithWithoutVAT"); 2871 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 2872 2873 <div class="u-margin-bottom"> 2874 @if (pointShopOnly) 2875 { 2876 <text> 2877 {{#if havePointPrice}} 2878 <div class="price price--product-list dw-mod">{{points}} @Translate("points")</div> 2879 @if (showCartButton) 2880 { 2881 <text> 2882 {{#unless canBePurchasedWithPoints}} 2883 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 2884 {{/unless}} 2885 </text> 2886 } 2887 {{else}} 2888 @Translate("Not available") 2889 {{/if}} 2890 </text> 2891 2892 } 2893 else 2894 { 2895 <div class="price price--product-list dw-mod">{{price}}</div> 2896 <div class="before-price {{onSale}} dw-mod">{{discount}}</div> 2897 if (showVATPrice) 2898 { 2899 <div class="vat-price vat-price--product-list u-margin-top dw-mod"> 2900 @if (isPricesWithVATEnabled) 2901 { 2902 <span>@Translate("excl. VAT")</span><span> ({{priceWithoutVAT}})</span> 2903 } 2904 else 2905 { 2906 <span>@Translate("incl. VAT")</span><span> ({{priceWithVAT}})</span> 2907 } 2908 </div> 2909 } 2910 <text> 2911 {{#if priceRRP}} 2912 <div><small>@Translate("RRP") {{priceRRP}}</small></div> 2913 {{/if}} 2914 </text> 2915 } 2916 </div> 2917 } 2918 2919 @helper RenderListViewItemViewButton() 2920 { 2921 string viewMoreText = listViewSettings.GetString("ViewMoreText"); 2922 viewMoreText = !string.IsNullOrEmpty(viewMoreText) ? viewMoreText : "View"; 2923 2924 @Render(new Link 2925 { 2926 Href = "{{link}}", 2927 Id = "CartButton_{{id}}", 2928 Title = Translate(viewMoreText), 2929 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 2930 ButtonLayout = ButtonLayout.Secondary, 2931 CssClass = "u-no-margin" 2932 }); 2933 } 2934 2935 @helper RenderListViewItemAddToCart() 2936 { 2937 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 2938 2939 var addToCartBtn = new AddToCart 2940 { 2941 WrapperCssClass = "buttons-collection--right", 2942 AddButton = new AddToCartButton 2943 { 2944 HideTitle = false, 2945 ProductId = "{{productId}}", 2946 VariantId = "{{variantid}}", 2947 UnitId = "{{unitId}}", 2948 ProductInfo = "{{productInfo}}", 2949 BuyForPoints = pointShopOnly, 2950 OnClick = "{{facebookPixelAction}}", 2951 ExtraAttributes = new Dictionary<string, string> 2952 { 2953 { "{{disabledBuyButton}}", "" } 2954 } 2955 } 2956 }; 2957 2958 if (!pointShopOnly) 2959 { 2960 addToCartBtn.QuantitySelector = new QuantitySelector 2961 { 2962 Id = "Quantity{{id}}" 2963 }; 2964 } 2965 2966 addToCartBtn.UnitSelector = new UnitSelector 2967 { 2968 OptionsContent = "{{#unitOptions}}{{>UnitOption}}{{/unitOptions}}", 2969 Id = "UnitOptions_{{id}}", 2970 SelectedOption = "{{unitName}}", 2971 CssClass = "{{#if hasOnlyOneUnit}}unit-selector--readonly{{/if}} {{hasUnits}}" 2972 }; 2973 2974 @Render(addToCartBtn) 2975 } 2976 2977 @helper RenderListViewItemActions() 2978 { 2979 bool showCartButton = listViewSettings.GetBoolean("ShowAddToCartButton"); 2980 bool showViewButton = listViewSettings.GetBoolean("ShowViewButton"); 2981 bool hasVariantSelector = listViewSettings.GetList("Variants") != null && listViewSettings.GetList("Variants").SelectedValue == "selector"; 2982 2983 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 2984 { 2985 if (showCartButton) 2986 { 2987 if (!showViewButton || hasVariantSelector) 2988 { 2989 <text>{{#if hideAddToCartButton}}</text> 2990 <div>@RenderListViewItemViewButton()</div> 2991 <text>{{else}}</text> 2992 @RenderListViewItemAddToCart() 2993 <text>{{/if}}</text> 2994 } 2995 else 2996 { 2997 <div>@RenderListViewItemViewButton()</div> 2998 } 2999 } 3000 else if (showViewButton) 3001 { 3002 <div>@RenderListViewItemViewButton()</div> 3003 } 3004 } 3005 else if (showViewButton) 3006 { 3007 <div>@RenderListViewItemViewButton()</div> 3008 } 3009 } 3010 3011 @helper RenderListViewItemDownloadButton() 3012 { 3013 <div class="grid__cell-footer u-margin-top"> 3014 <div class="grid__cell"> 3015 <button type="button" class="btn btn--primary btn--condensed u-no-margin u-pull--right dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 3016 <i class="fas fa-plus js-button-icon"></i> 3017 <span class="js-button-text">@Translate("Add")</span> 3018 </button> 3019 </div> 3020 </div> 3021 } 3022 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3023 @using Dynamicweb.Core 3024 @using System 3025 @using System.Web 3026 @using System.Collections.Generic 3027 @using Dynamicweb.Rapido.Blocks 3028 @using Dynamicweb.Rapido.Blocks.Components 3029 @using Dynamicweb.Rapido.Blocks.Components.General 3030 @using Dynamicweb.Rapido.Services 3031 3032 @functions { 3033 BlocksPage gridViewPage = BlocksPage.GetBlockPage("ProductList"); 3034 Dynamicweb.Frontend.ItemViewModel gridViewSettings = null; 3035 } 3036 3037 @if (Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableGridView")) 3038 { 3039 gridViewSettings = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView"); 3040 3041 BlocksPage gridViewPage = BlocksPage.GetBlockPage("ProductList"); 3042 3043 gridViewPage.Add("Views", new Block 3044 { 3045 Id = "ProductGridItemContainer", 3046 Name = "th", 3047 SortId = 20 3048 }); 3049 3050 Block gridViewScripts = new Block 3051 { 3052 Id = "GridViewScripts", 3053 SortId = 20, 3054 Template = GridView(), 3055 BlocksList = new List<Block> { 3056 new Block 3057 { 3058 Id = "GridViewItem", 3059 SortId = 10, 3060 Template = RenderGridViewItem(), 3061 SkipRenderBlocksList = true, 3062 BlocksList = new List<Block> { 3063 new Block 3064 { 3065 Id = "GridViewItemHiddenProperties", 3066 SortId = 10, 3067 Template = RenderGridViewItemHiddenProperties() 3068 }, 3069 new Block 3070 { 3071 Id = "GridViewItemImageContainer", 3072 SortId = 20, 3073 SkipRenderBlocksList = true, 3074 Template = RenderGridViewItemImageContainer(), 3075 BlocksList = new List<Block> { 3076 new Block 3077 { 3078 Id = "GridViewItemImage", 3079 SortId = 10, 3080 Template = RenderGridViewItemImage() 3081 }, 3082 new Block 3083 { 3084 Id = "GridViewItemStickers", 3085 SortId = 20, 3086 Template = RenderGridViewItemStickers() 3087 } 3088 } 3089 }, 3090 new Block 3091 { 3092 Id = "GridViewItemInfoContainer", 3093 SortId = 30, 3094 SkipRenderBlocksList = true, 3095 Template = RenderGridViewItemInfoContainer(), 3096 BlocksList = new List<Block> { 3097 new Block 3098 { 3099 Id = "GridViewItemTitle", 3100 SortId = 10, 3101 Template = RenderGridViewItemTitle() 3102 } 3103 } 3104 }, 3105 new Block 3106 { 3107 Id = "GridViewItemFooter", 3108 SortId = 40, 3109 SkipRenderBlocksList = true, 3110 Template = RenderGridViewItemFooter(), 3111 BlocksList = new List<Block> { 3112 new Block 3113 { 3114 Id = "GridViewItemActions", 3115 SortId = 10, 3116 Template = RenderGridViewItemActions() 3117 } 3118 } 3119 } 3120 } 3121 } 3122 } 3123 }; 3124 gridViewPage.Add("BottomSnippets", gridViewScripts); 3125 3126 //favorites 3127 bool gridViewShowFavoriteButton = !gridViewSettings.GetBoolean("HideFavoriteButton"); 3128 3129 if (gridViewShowFavoriteButton) 3130 { 3131 gridViewPage.Add("GridViewItemImageContainer", new Block 3132 { 3133 Id = "GridViewItemFavorites", 3134 SortId = 30, 3135 Template = RenderGridViewItemFavorites() 3136 }); 3137 } 3138 3139 //number 3140 bool gridViewShowNumber = gridViewSettings.GetBoolean("ShowProductNumber"); 3141 3142 if (gridViewShowNumber) 3143 { 3144 gridViewPage.Add("GridViewItemInfoContainer", new Block 3145 { 3146 Id = "GridViewItemNumber", 3147 SortId = 20, 3148 Template = RenderGridViewItemNumber() 3149 }); 3150 } 3151 3152 //price 3153 bool gridViewShowPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 3154 if (gridViewShowPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 3155 { 3156 gridViewPage.Add("GridViewItemInfoContainer", new Block 3157 { 3158 Id = "GridViewItemPrice", 3159 SortId = 30, 3160 Template = RenderGridViewItemPrice() 3161 }); 3162 } 3163 3164 //stock 3165 bool gridViewShowStock = gridViewSettings.GetBoolean("ShowStockAndShipping"); 3166 3167 if (User.IsStockInfoAllowed() && gridViewShowStock) 3168 { 3169 gridViewPage.Add("GridViewItemFooter", new Block 3170 { 3171 Id = "GridViewItemStockAndDelivery", 3172 SortId = 20, 3173 Template = RenderGridViewItemStockAndDelivery() 3174 }); 3175 } 3176 3177 //static variants 3178 bool gridViewShowStaticVariants = gridViewSettings.GetBoolean("ShowStaticVariants"); 3179 3180 if (gridViewShowStaticVariants) 3181 { 3182 gridViewPage.Add("GridViewItemFooter", new Block 3183 { 3184 Id = "GridViewItemStaticVariants", 3185 SortId = 30, 3186 Template = RenderGridViewItemStaticVariants() 3187 }); 3188 } 3189 3190 //download button 3191 bool gridViewShowAddToDownloadButton = gridViewSettings.GetBoolean("ShowAddToDownloadButton"); 3192 3193 if (gridViewShowAddToDownloadButton && Pageview.User != null) 3194 { 3195 gridViewPage.Add("GridViewItemFooter", new Block 3196 { 3197 Id = "GridViewItemDownloadButton", 3198 SortId = 40, 3199 Template = RenderGridViewItemDownloadButton() 3200 }); 3201 } 3202 } 3203 3204 @helper GridView() 3205 { 3206 int columnsCount = gridViewSettings.GetList("Columns") != null ? Converter.ToInt32(gridViewSettings.GetList("Columns").SelectedValue) : 3; 3207 string imageZoomOnHover = gridViewSettings.GetBoolean("HoverImageZoom") ? "image-hover--zoom" : ""; 3208 3209 <script id="ProductGridItemContainer" type="text/x-template"> 3210 {{#.}} 3211 <div id="Product{{id}}" data-template="GridViewItem" data-preloader="overlay" class="grid__col-lg-@(12 / columnsCount) grid__col-md-@(12 / columnsCount) grid__col-sm-@(12 / columnsCount) grid__col-xs-6 product-list__grid-item @imageZoomOnHover dw-mod"> 3212 {{#Product}} 3213 {{>GridViewItem}} 3214 {{/Product}} 3215 </div> 3216 {{/.}} 3217 </script> 3218 } 3219 3220 @helper RenderGridViewItem() 3221 { 3222 List<Block> subBlocks = gridViewPage.GetBlockListById("GridViewItem"); 3223 3224 <script id="GridViewItem" type="text/x-template"> 3225 {{#.}} 3226 <div class="grid__col--auto js-product-scroll-trigger u-no-padding u-full-height" data-params="{{googleImpression}}"> 3227 @RenderBlockList(subBlocks) 3228 </div> 3229 {{/.}} 3230 </script> 3231 } 3232 3233 @helper RenderGridViewItemHiddenProperties() 3234 { 3235 <input type="hidden" name="ProductLoopCounter{{id}}" value="{{id}}" /> 3236 <input type="hidden" name="ProductID{{id}}" value="{{productId}}" /> 3237 <input type="hidden" name="VariantID{{id}}" value="{{variantid}}" id="Variant_{{id}}" /> 3238 <input type="hidden" name="UnitID{{id}}" value="{{unitId}}" id="Unit_{{id}}" /> 3239 } 3240 3241 @helper RenderGridViewItemImageContainer() 3242 { 3243 List<Block> subBlocks = gridViewPage.GetBlockListById("GridViewItemImageContainer"); 3244 3245 <div class="grid__cell product-list__grid-item__image dw-mod {{noImage}}"> 3246 @RenderBlockList(subBlocks) 3247 </div> 3248 } 3249 3250 @helper RenderGridViewItemImage() 3251 { 3252 bool secondaryImage = gridViewSettings.GetString("HoverAlternatineImage") != null ? gridViewSettings.GetBoolean("HoverAlternatineImage") : false; 3253 3254 <a href="{{link}}" 3255 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" 3256 title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}" 3257 class="u-block u-position-relative image-hover__wrapper dw-mod"> 3258 <img class="grid__cell-img grid__cell-img--centered u-padding b-lazy" src="/Files/Images/placeholder.gif" 3259 data-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop=5&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{image}}" 3260 @if (secondaryImage) { 3261 <text> 3262 {{#if secondaryImage}} 3263 data-secondary-image-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop=5&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{secondaryImage}}" 3264 {{/if}} 3265 </text> 3266 } 3267 alt="{{name}}{{#if variantName}}, {{variantName}}{{/if}}" /> 3268 </a> 3269 } 3270 3271 @helper RenderGridViewItemStickers() 3272 { 3273 <text> 3274 {{#StickersContainers}} 3275 {{>StickersContainer}} 3276 {{/StickersContainers}} 3277 </text> 3278 } 3279 3280 @helper RenderGridViewItemFavorites() 3281 { 3282 <div class="favorites favorites--for-grid-view u-pull--right {{hasVariants}} dw-mod" {{hasVariants}}> 3283 {{#Favorite}} 3284 {{>FavoriteTemplate}} 3285 {{/Favorite}} 3286 </div> 3287 } 3288 3289 @helper RenderGridViewItemInfoContainer() 3290 { 3291 List<Block> subBlocks = gridViewPage.GetBlockListById("GridViewItemInfoContainer"); 3292 3293 <div class="grid__cell product-list__grid-item__price-info dw-mod"> 3294 @RenderBlockList(subBlocks) 3295 </div> 3296 } 3297 3298 @helper RenderGridViewItemTitle() 3299 { 3300 <a href="{{link}}" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}"> 3301 <h6 class="u-condensed-text">{{name}}{{#if variantName}}, {{variantName}}{{/if}}</h6> 3302 </a> 3303 } 3304 3305 @helper RenderGridViewItemNumber() 3306 { 3307 <div class="item-number dw-mod">{{number}}</div> 3308 } 3309 3310 @helper RenderGridViewItemPrice() 3311 { 3312 int columnsCount = gridViewSettings.GetList("Columns") != null ? Converter.ToInt32(gridViewSettings.GetList("Columns").SelectedValue) : 4; 3313 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3314 bool showCartButton = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("ShowAddToCartButton"); 3315 bool showVATPrice = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("ShowBothPricesWithWithoutVAT"); 3316 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 3317 3318 if (pointShopOnly) 3319 { 3320 <text> 3321 {{#if havePointPrice}} 3322 <div class="price price--product-list dw-mod">{{points}} @Translate("points")</div> 3323 @if (showCartButton) 3324 { 3325 <text> 3326 {{#unless canBePurchasedWithPoints}} 3327 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 3328 {{/unless}} 3329 </text> 3330 } 3331 {{else}} 3332 @Translate("Not available") 3333 {{/if}} 3334 </text> 3335 3336 } 3337 else 3338 { 3339 <div class="price price--product-list dw-mod">{{price}}</div> 3340 <div class="before-price {{onSale}} dw-mod">{{discount}}</div> 3341 if (showVATPrice) 3342 { 3343 <div class="vat-price vat-price--product-list u-margin-top dw-mod"> 3344 @if (columnsCount <= 4) { 3345 if (isPricesWithVATEnabled) 3346 { 3347 <span>@Translate("excl. VAT")</span><span> ({{priceWithoutVAT}})</span> 3348 } 3349 else 3350 { 3351 <span>@Translate("incl. VAT")</span><span> ({{priceWithVAT}})</span> 3352 } 3353 } else { 3354 if (isPricesWithVATEnabled) 3355 { 3356 <div>@Translate("excl. VAT")</div><div>({{priceWithoutVAT}})</div> 3357 } 3358 else 3359 { 3360 <div>@Translate("incl. VAT")</div><div>({{priceWithVAT}})</div> 3361 } 3362 } 3363 </div> 3364 } 3365 <text> 3366 {{#if priceRRP}} 3367 <div><small>@Translate("RRP") {{priceRRP}}</small></div> 3368 {{/if}} 3369 </text> 3370 } 3371 } 3372 3373 @helper RenderGridViewItemFooter() 3374 { 3375 List<Block> subBlocks = gridViewPage.GetBlockListById("GridViewItemFooter"); 3376 bool showStaticVariants = gridViewSettings.GetBoolean("ShowStaticVariants"); 3377 string footerClasses = showStaticVariants ? "u-min-h120px" : ""; 3378 3379 <div class="product-list__grid-item__footer @footerClasses dw-mod"> 3380 @RenderBlockList(subBlocks) 3381 </div> 3382 } 3383 3384 @helper RenderGridViewItemViewButton() 3385 { 3386 string viewMoreText = gridViewSettings.GetString("ViewMoreText"); 3387 viewMoreText = !string.IsNullOrEmpty(viewMoreText) ? viewMoreText : "View"; 3388 3389 @Render(new Link 3390 { 3391 Href = "{{link}}", 3392 Id = "CartButton_{{id}}", 3393 Title = Translate(viewMoreText), 3394 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 3395 ButtonLayout = ButtonLayout.Secondary, 3396 CssClass = "u-no-margin" 3397 }); 3398 } 3399 3400 @helper RenderGridViewItemAddToCart() 3401 { 3402 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3403 string wrapperClass = "buttons-collection--center"; 3404 int columnsCount = gridViewSettings.GetList("Columns") != null ? Converter.ToInt32(gridViewSettings.GetList("Columns").SelectedValue) : 4; 3405 bool hideButtonText = columnsCount >= 4 || Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet"; 3406 3407 if (pointShopOnly && columnsCount <= 4) 3408 { 3409 hideButtonText = false; 3410 } 3411 3412 var addToCartBtn = new AddToCart 3413 { 3414 WrapperCssClass = wrapperClass, 3415 AddButton = new AddToCartButton 3416 { 3417 HideTitle = hideButtonText, 3418 ProductId = "{{productId}}", 3419 VariantId = "{{variantid}}", 3420 UnitId = "{{unitId}}", 3421 ProductInfo = "{{productInfo}}", 3422 BuyForPoints = pointShopOnly, 3423 OnClick = "{{facebookPixelAction}}", 3424 ExtraAttributes = new Dictionary<string, string> 3425 { 3426 { "{{disabledBuyButton}}", "" } 3427 } 3428 } 3429 }; 3430 3431 if (!pointShopOnly) 3432 { 3433 addToCartBtn.QuantitySelector = new QuantitySelector 3434 { 3435 Id = "Quantity{{id}}" 3436 }; 3437 } 3438 3439 @Render(addToCartBtn) 3440 } 3441 3442 @helper RenderGridViewItemActions() 3443 { 3444 bool showCartButton = gridViewSettings.GetBoolean("ShowAddToCartButton"); 3445 bool showViewButton = gridViewSettings.GetBoolean("ShowViewButton"); 3446 3447 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 3448 { 3449 if (showCartButton) 3450 { 3451 if (!showViewButton) 3452 { 3453 <text>{{#if hideAddToCartButton}}</text> 3454 <div>@RenderGridViewItemViewButton()</div> 3455 <text>{{else}}</text> 3456 @RenderGridViewItemAddToCart() 3457 <text>{{/if}}</text> 3458 } 3459 else 3460 { 3461 @RenderGridViewItemAddToCart() 3462 } 3463 } 3464 else if (showViewButton) 3465 { 3466 <div>@RenderGridViewItemViewButton()</div> 3467 } 3468 } 3469 else if (showViewButton) 3470 { 3471 <div>@RenderGridViewItemViewButton()</div> 3472 } 3473 } 3474 3475 @helper RenderGridViewItemStockAndDelivery() 3476 { 3477 <text>{{#if stockText}}</text> 3478 <div class="u-margin-top"> 3479 <div><span class="stock-icon {{stockState}} u-no-margin dw-mod" title="{{stockText}}"></span> {{stockText}}</div> 3480 <div> 3481 {{#if deliveryText}} 3482 {{deliveryText}} 3483 {{else}} 3484 - 3485 {{/if}} 3486 </div> 3487 </div> 3488 <text>{{/if}}</text> 3489 } 3490 3491 @helper RenderGridViewItemStaticVariants() 3492 { 3493 <text> 3494 {{#Variants}} 3495 {{>StaticVariantsTemplate}} 3496 {{/Variants}} 3497 3498 {{#ifCond variantGroupsCount '>' 1}} 3499 <div class="static-variant"> 3500 @Translate("More options available") 3501 </div> 3502 {{/ifCond}} 3503 3504 {{#ifCond variantGroupsCount '==' 0}} 3505 <div class="static-variant"></div> 3506 {{/ifCond}} 3507 </text> 3508 } 3509 3510 @helper RenderGridViewItemDownloadButton() 3511 { 3512 <button type="button" class="btn btn--primary u-no-margin u-margin-top btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 3513 @Render(new Icon { Prefix = "fas", Name = "fa-plus", CssClass = "js-button-icon" }) 3514 <span class="js-button-text">@Translate("Add")</span> 3515 </button> 3516 } 3517 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3518 @using Dynamicweb.Core 3519 @using System 3520 @using System.Web 3521 @using System.Collections.Generic 3522 @using Dynamicweb.Rapido.Blocks 3523 @using Dynamicweb.Rapido.Blocks.Components 3524 @using Dynamicweb.Rapido.Blocks.Components.General 3525 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 3526 @using Dynamicweb.Rapido.Services 3527 3528 @functions { 3529 BlocksPage detailsViewPage = BlocksPage.GetBlockPage("ProductList"); 3530 Dynamicweb.Frontend.ItemViewModel detailsViewSettings = null; 3531 3532 /* this function need because in details view we have specipfic situation 3533 * when price need to be placed between unit selector and quantity selector 3534 */ 3535 3536 UnitSelector getUnitsSelector() 3537 { 3538 return new UnitSelector 3539 { 3540 OptionsContent = "{{#unitOptions}}{{>UnitOption}}{{/unitOptions}}", 3541 Id = "UnitOptions_{{id}}", 3542 SelectedOption = "{{unitName}}", 3543 CssClass = "product-list__details-units-selector {{#if hasOnlyOneUnit}}unit-selector--readonly{{/if}} {{hasUnits}}" 3544 }; 3545 } 3546 } 3547 3548 @if (Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableDetailsView")) 3549 { 3550 detailsViewSettings = Pageview.AreaSettings.GetItem("ProductList").GetItem("DetailsView"); 3551 3552 detailsViewPage.Add("Views", new Block 3553 { 3554 Id = "ProductDetailsItemContainer", 3555 Name = "list", 3556 SortId = 30 3557 }); 3558 3559 Block detailsViewScripts = new Block 3560 { 3561 Id = "DetailsViewScripts", 3562 SortId = 30, 3563 Template = DetailsView(), 3564 BlocksList = new List<Block> 3565 { 3566 new Block 3567 { 3568 Id = "DetailsViewItem", 3569 SortId = 10, 3570 Template = RenderDetailsViewItem(), 3571 SkipRenderBlocksList = true, 3572 BlocksList = new List<Block> { 3573 new Block 3574 { 3575 Id = "DetailsViewItemHiddenProperties", 3576 SortId = 10, 3577 Template = RenderDetailsViewItemHiddenProperties() 3578 }, 3579 new Block 3580 { 3581 Id = "DetailsViewItemLeft", 3582 SortId = 10, 3583 Design = new Design 3584 { 3585 CssClass = "product-list__details-item__left grid__cell dw-mod" 3586 }, 3587 BlocksList = new List<Block> { 3588 new Block 3589 { 3590 Id = "DetailsViewItemInfoContainer", 3591 SortId = 20, 3592 Design = new Design 3593 { 3594 CssClass = "product-list__details-info dw-mod" 3595 }, 3596 BlocksList = new List<Block> { 3597 new Block 3598 { 3599 Id = "DetailsViewItemTitle", 3600 SortId = 10, 3601 Template = RenderDetailsViewItemTitle() 3602 }, 3603 new Block 3604 { 3605 Id = "DetailsViewItemStickers", 3606 SortId = 50, 3607 Template = RenderDetailsViewItemStickers() 3608 } 3609 } 3610 } 3611 } 3612 }, 3613 new Block 3614 { 3615 Id = "DetailsViewItemRight", 3616 SortId = 20, 3617 Design = new Design 3618 { 3619 CssClass = "product-list__details-item__right grid__cell dw-mod" 3620 }, 3621 BlocksList = new List<Block> { 3622 new Block { 3623 Id = "DetailsViewItemRightBottom", 3624 SortId = 20, 3625 Design = new Design 3626 { 3627 CssClass = "u-flex product-list__details-right-bottom-section dw-mod" 3628 }, 3629 BlocksList = new List<Block> { 3630 new Block 3631 { 3632 Id = "DetailsViewItemActions", 3633 SortId = 30, 3634 Template = RenderDetailsViewItemActions() 3635 } 3636 } 3637 } 3638 } 3639 } 3640 } 3641 } 3642 } 3643 }; 3644 detailsViewPage.Add("BottomSnippets", detailsViewScripts); 3645 3646 //image 3647 bool detailsViewShowImage = detailsViewSettings.GetBoolean("ShowImage"); 3648 3649 if (detailsViewShowImage) 3650 { 3651 detailsViewPage.Add("DetailsViewItemLeft", new Block 3652 { 3653 Id = "DetailsViewItemImage", 3654 SortId = 10, 3655 Template = RenderDetailsViewItemImage() 3656 }); 3657 } 3658 3659 //number 3660 bool detailsViewShowNumber = detailsViewSettings.GetBoolean("ShowProductNumber"); 3661 3662 if (detailsViewShowNumber) 3663 { 3664 detailsViewPage.Add("DetailsViewItemInfoContainer", new Block 3665 { 3666 Id = "ProductDetailsItemNumber", 3667 SortId = 30, 3668 Template = RenderDetailsViewItemNumber() 3669 }); 3670 } 3671 3672 //static variants 3673 bool detailsViewShowStaticVariants = detailsViewSettings.GetBoolean("ShowStaticVariants"); 3674 3675 if (detailsViewShowStaticVariants) 3676 { 3677 detailsViewPage.Add("DetailsViewItemInfoContainer", new Block 3678 { 3679 Id = "DetailsViewItemStaticVariants", 3680 SortId = 30, 3681 Template = RenderDetailsViewItemStaticVariants() 3682 }); 3683 } 3684 3685 //stock 3686 bool detailsViewShowStock = detailsViewSettings.GetBoolean("ShowStockAndShipping"); 3687 3688 if (User.IsStockInfoAllowed() && detailsViewShowStock) 3689 { 3690 detailsViewPage.Add("DetailsViewItemInfoContainer", new Block 3691 { 3692 Id = "DetailsViewItemStock", 3693 SortId = 40, 3694 Template = RenderDetailsViewItemStock() 3695 }); 3696 } 3697 3698 //price 3699 bool detailsViewShowPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 3700 if (detailsViewShowPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 3701 { 3702 var separatedUnitSelector = getUnitsSelector(); 3703 separatedUnitSelector.CssClass += " product-list__details-units-selector--separated"; 3704 3705 detailsViewPage.Add("DetailsViewItemRightBottom", new Block { 3706 Id = "DetailsViewUnitSelector", 3707 SortId = 10, 3708 Component = separatedUnitSelector 3709 }); 3710 3711 detailsViewPage.Add("DetailsViewItemRightBottom", new Block 3712 { 3713 Id = "ProductDetailsItemPrice", 3714 SortId = 20, 3715 Template = RenderDetailsViewItemPrice() 3716 }); 3717 } 3718 3719 //favorites 3720 bool detailsViewShowFavoriteButton = !detailsViewSettings.GetBoolean("HideFavoriteButton"); 3721 3722 if (detailsViewShowFavoriteButton && Pageview.User != null) 3723 { 3724 detailsViewPage.Add("DetailsViewItemRightBottom", new Block 3725 { 3726 Id = "DetailsViewItemFavorites", 3727 SortId = 40, 3728 Template = RenderDetailsViewItemFavorites() 3729 }); 3730 } 3731 3732 //download button 3733 bool detailsViewShowAddToDownloadButton = detailsViewSettings.GetBoolean("ShowAddToDownloadButton"); 3734 3735 if (detailsViewShowAddToDownloadButton && Pageview.User != null) 3736 { 3737 detailsViewPage.Add("DetailsViewItemRightBottom", new Block 3738 { 3739 Id = "DetailsViewItemDownloadButton", 3740 SortId = 20, 3741 Template = RenderDetailsViewItemDownloadButton() 3742 }); 3743 } 3744 } 3745 3746 @helper DetailsView() 3747 { 3748 <script id="ProductDetailsItemContainer" type="text/x-template"> 3749 {{#.}} 3750 <div id="Product{{id}}" data-template="DetailsViewItem" data-preloader="overlay" class="grid__col-12 u-no-padding-y js-product dw-mod" style="z-index: {{zIndex}}"> 3751 {{#Product}} 3752 {{>DetailsViewItem}} 3753 {{/Product}} 3754 </div> 3755 {{/.}} 3756 </script> 3757 } 3758 3759 @helper RenderDetailsViewItem() 3760 { 3761 List<Block> subBlocks = detailsViewPage.GetBlockListById("DetailsViewItem"); 3762 3763 <script id="DetailsViewItem" type="text/x-template"> 3764 {{#.}} 3765 <div class="product-list__details-item grid__col-12 dw-mod js-product-scroll-trigger" data-params="{{googleImpression}}"> 3766 @RenderBlockList(subBlocks) 3767 </div> 3768 {{/.}} 3769 </script> 3770 } 3771 3772 @helper RenderDetailsViewItemHiddenProperties() 3773 { 3774 <input type="hidden" name="ProductLoopCounter{{id}}" value="{{id}}" /> 3775 <input type="hidden" name="ProductID{{id}}" value="{{productId}}" /> 3776 <input type="hidden" name="VariantID{{id}}" value="{{variantid}}" id="Variant_{{id}}" /> 3777 <input type="hidden" name="UnitID{{id}}" value="{{unitId}}" id="Unit_{{id}}" /> 3778 } 3779 3780 @helper RenderDetailsViewItemImage() 3781 { 3782 <div class="lightbox"> 3783 <a href="{{link}}" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}"> 3784 <img class="lightbox__image {{noImage}}" src="/Admin/Public/GetImage.ashx?width=220&amp;height=220&amp;crop=5&amp;Compression=75&amp;image={{image}}" alt="{{name}}{{#if variantName}}, {{variantName}}{{/if}}" /> 3785 <div class="u-margin-right {{noImage}}"> 3786 <img class="b-lazy product-list__details-image" src="/Files/Images/placeholder.gif" 3787 data-src="/Admin/Public/GetImage.ashx?width=75&amp;height=55&amp;crop=5&FillCanvas=true&amp;Compression=75&amp;image={{image}}" 3788 alt="{{name}}{{#if variantName}}, {{variantName}}{{/if}}" /> 3789 </div> 3790 </a> 3791 </div> 3792 } 3793 3794 @helper RenderDetailsViewItemTitle() 3795 { 3796 <a href="{{link}}" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}" class="product-list__details-title"> 3797 <h6 class="u-no-margin">{{name}}{{#if variantName}}, {{variantName}}{{/if}}</h6> 3798 </a> 3799 } 3800 3801 @helper RenderDetailsViewItemNumber() 3802 { 3803 <div class="item-number item-number--compressed dw-mod"> 3804 <div class="item-number dw-mod">{{number}}</div> 3805 </div> 3806 } 3807 3808 @helper RenderDetailsViewItemStaticVariants() 3809 { 3810 <span> 3811 {{#Variants}} 3812 {{>StaticVariantsTemplate}} 3813 {{/Variants}} 3814 </span> 3815 <text> 3816 {{#ifCond variantGroupsCount '>' 1}} 3817 <div class="static-variant"> 3818 @Translate("More options available") 3819 </div> 3820 {{/ifCond}} 3821 </text> 3822 } 3823 3824 @helper RenderDetailsViewItemStock() 3825 { 3826 <text>{{#if stockText}}</text> 3827 <div class="item-number item-number--compressed dw-mod"> 3828 <span> 3829 <span class="stock-icon {{stockState}} u-no-margin dw-mod" title="{{stockText}}"></span> 3830 <span class="u-margin-right--lg"> {{stockText}}</span> 3831 {{deliveryText}} 3832 </span> 3833 </div> 3834 <text>{{/if}}</text> 3835 } 3836 3837 @helper RenderDetailsViewItemStickers() 3838 { 3839 <div class="grid__cell-footer stickers-container stickers-container--row u-margin-top dw-mod"> 3840 {{#StickersContainers}} 3841 {{#Stickers}} 3842 {{>MiniSticker}} 3843 {{/Stickers}} 3844 {{/StickersContainers}} 3845 </div> 3846 } 3847 3848 @helper RenderDetailsViewItemPrice() 3849 { 3850 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3851 bool showCartButton = Pageview.AreaSettings.GetItem("ProductList").GetItem("DetailsView").GetBoolean("ShowAddToCartButton"); 3852 bool showVATPrice = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("ShowBothPricesWithWithoutVAT"); 3853 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 3854 3855 <div class="product-list__details-price"> 3856 @if (pointShopOnly) 3857 { 3858 <text> 3859 {{#if havePointPrice}} 3860 <div class="price price--product-list price--micro dw-mod">{{points}} @Translate("points")</div> 3861 @if (showCartButton) 3862 { 3863 <text> 3864 {{#unless canBePurchasedWithPoints}} 3865 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 3866 {{/unless}} 3867 </text> 3868 } 3869 {{else}} 3870 @Translate("Not available") 3871 {{/if}} 3872 </text> 3873 3874 } 3875 else 3876 { 3877 <div class="price price--product-list price--micro dw-mod">{{price}}</div> 3878 <div class="before-price {{onSale}} before-price--micro dw-mod">{{discount}}</div> 3879 if (showVATPrice) 3880 { 3881 <div class="vat-price vat-price--product-list price--micro u-margin-top dw-mod"> 3882 @if (isPricesWithVATEnabled) 3883 { 3884 <span>@Translate("excl. VAT")</span><span> ({{priceWithoutVAT}})</span> 3885 } 3886 else 3887 { 3888 <span>@Translate("incl. VAT")</span><span> ({{priceWithVAT}})</span> 3889 } 3890 </div> 3891 } 3892 <text> 3893 {{#if priceRRP}} 3894 <div><small>@Translate("RRP") {{priceRRP}}</small></div> 3895 {{/if}} 3896 </text> 3897 } 3898 </div> 3899 } 3900 3901 @helper RenderDetailsViewItemFavorites() 3902 { 3903 <div class="favorites product-list__details-favorites {{hasVariants}} dw-mod" {{hasVariants}}> 3904 {{#Favorite}} 3905 {{>FavoriteTemplate}} 3906 {{/Favorite}} 3907 </div> 3908 } 3909 3910 @helper RenderDetailsViewItemViewButton() 3911 { 3912 string viewMoreText = detailsViewSettings.GetString("ViewMoreText"); 3913 viewMoreText = !string.IsNullOrEmpty(viewMoreText) ? viewMoreText : "View"; 3914 3915 <div class="product-list__details-actions"> 3916 @Render(new Link 3917 { 3918 Href = "{{link}}", 3919 Id = "CartButton_{{id}}", 3920 Title = Translate(viewMoreText), 3921 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 3922 ButtonLayout = ButtonLayout.Secondary, 3923 CssClass = "u-no-margin" 3924 }) 3925 </div> 3926 } 3927 3928 @helper RenderDetailsViewItemAddToCart() 3929 { 3930 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3931 bool showPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 3932 3933 var addToCartBtn = new AddToCart 3934 { 3935 AddButton = new AddToCartButton 3936 { 3937 HideTitle = true, 3938 ProductId = "{{productId}}", 3939 VariantId = "{{variantid}}", 3940 UnitId = "{{unitId}}", 3941 ProductInfo = "{{productInfo}}", 3942 BuyForPoints = pointShopOnly, 3943 OnClick = "{{facebookPixelAction}}", 3944 ExtraAttributes = new Dictionary<string, string> 3945 { 3946 { "{{disabledBuyButton}}", "" } 3947 } 3948 } 3949 }; 3950 3951 if (!pointShopOnly) 3952 { 3953 addToCartBtn.QuantitySelector = new QuantitySelector 3954 { 3955 Id = "Quantity{{id}}" 3956 }; 3957 } 3958 3959 if (!showPrice) 3960 { 3961 addToCartBtn.UnitSelector = getUnitsSelector(); 3962 } 3963 3964 <div class="product-list__details-actions"> 3965 @Render(addToCartBtn) 3966 </div> 3967 } 3968 3969 @helper RenderDetailsViewItemActions() 3970 { 3971 bool showCartButton = detailsViewSettings.GetBoolean("ShowAddToCartButton"); 3972 bool showViewButton = detailsViewSettings.GetBoolean("ShowViewButton"); 3973 3974 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 3975 { 3976 if (showCartButton) 3977 { 3978 if (!showViewButton) 3979 { 3980 @RenderDetailsViewItemAddToCart() 3981 } 3982 else 3983 { 3984 <text>{{#if hideAddToCartButton}}</text> 3985 @RenderDetailsViewItemViewButton() 3986 <text>{{else}}</text> 3987 @RenderDetailsViewItemAddToCart() 3988 <text>{{/if}}</text> 3989 } 3990 } 3991 else if (showViewButton) 3992 { 3993 @RenderDetailsViewItemViewButton() 3994 } 3995 } 3996 else if (showViewButton) 3997 { 3998 @RenderDetailsViewItemViewButton() 3999 } 4000 } 4001 4002 @helper RenderDetailsViewItemDownloadButton() 4003 { 4004 <button type="button" class="btn btn--primary u-no-margin u-margin-left btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 4005 @Render(new Icon { Prefix = "fas", Name = "fa-plus", CssClass = "js-button-icon" }) 4006 </button> 4007 } 4008 4009 4010 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4011 @using Dynamicweb.Core 4012 @using System 4013 @using System.Web 4014 @using System.Collections.Generic 4015 @using Dynamicweb.Rapido.Blocks 4016 4017 @{ 4018 BlocksPage productListPromotionsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4019 4020 Block productListPromotions = new Block 4021 { 4022 Id = "Promotions", 4023 SortId = 10, 4024 Template = RenderProductListPromotions() 4025 }; 4026 productListPromotionsBlocksPage.Add("PageContainer", productListPromotions); 4027 } 4028 4029 @helper RenderProductListPromotions() 4030 { 4031 @*This is part of a script template *@ 4032 4033 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 4034 bool isFavoriteList = !string.IsNullOrEmpty(listId); 4035 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "u-no-padding" : ""; 4036 4037 if (!isFavoriteList) 4038 { 4039 switch (Pageview.AreaSettings.GetItem("ProductList").GetList("PromotionBlockDesign").SelectedValue) 4040 { 4041 case "OnlyText": 4042 <article class="grid__col-12 u-margin-bottom @smallDeviceCss"> 4043 <h1>{{groupName}}</h1> 4044 {{{groupDescription}}} 4045 </article> 4046 break; 4047 case "TextAndImage": 4048 <article class="grid__col-12 u-margin-bottom @smallDeviceCss"> 4049 <div class="grid grid--bleed"> 4050 <div class="grid__col-md-6"> 4051 <h1>{{groupName}}</h1> 4052 {{{groupDescription}}} 4053 </div> 4054 {{#ifCond groupPromotionImage "!==" ""}} 4055 <div class="grid__col-md-6"> 4056 <img src="/Admin/Public/GetImage.ashx?width=600&crop=5&Compression=75&DoNotUpscale=true&image={{groupPromotionImage}}" alt="{{groupName}}" class="background-image__cover" /> 4057 </div> 4058 {{/ifCond}} 4059 </div> 4060 </article> 4061 break; 4062 case "Banner": 4063 <text> 4064 {{#ifCond groupPromotionImage "!==" ""}} 4065 <article class="grid__col-12 u-margin-bottom @smallDeviceCss"> 4066 <div class="u-color-light grid center-container center-container--with-background-image grid__col--bg" style="background-image:url('{{groupPromotionImage}}');"> 4067 <div class="grid__col-12 u-middle"> 4068 <div class="grid__cell"> 4069 {{{groupDescription}}} 4070 </div> 4071 </div> 4072 </div> 4073 </article> 4074 {{/ifCond}} 4075 </text> 4076 break; 4077 } 4078 } 4079 } 4080 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4081 @using Dynamicweb.Core 4082 @using System 4083 @using System.Web 4084 @using System.Collections.Generic 4085 @using Dynamicweb.Rapido.Blocks 4086 4087 @{ 4088 BlocksPage productListMenuBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4089 4090 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && 4091 Converter.ToString(Pageview.Page.PropertyItem["LeftMenu"]) == "True" && 4092 Pageview.Page.NavigationSettings != null && 4093 Pageview.Page.NavigationSettings.UseEcomGroups) { 4094 4095 Block productListMenuBlock = new Block 4096 { 4097 Id = "Menu", 4098 SortId = 20, 4099 Template = RenderProductListMenu() 4100 }; 4101 4102 productListMenuBlocksPage.Add("Navigation", productListMenuBlock); 4103 } 4104 } 4105 4106 @helper RenderProductListMenu() 4107 { 4108 var navigationMarkup = RenderNavigation(new 4109 { 4110 id = "leftnav", 4111 cssclass = "dwnavigation", 4112 startLevel = 1, 4113 endlevel = 5, 4114 template = "LeftNavigation.xslt", 4115 mode = "ecom" 4116 }); 4117 4118 <h2 class="u-margin-bottom">@Translate("Product categories")</h2> 4119 4120 <div class="u-padding-bottom--lg"> 4121 @navigationMarkup 4122 </div> 4123 } 4124 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4125 @using Dynamicweb.Core 4126 @using System 4127 @using System.Web 4128 @using System.Collections.Generic 4129 @using Dynamicweb.Rapido.Blocks 4130 4131 @{ 4132 BlocksPage productListFacetsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4133 4134 string facetsBlockViewMode = !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode")) ? Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode").ToLower() : "left"; 4135 4136 if (facetsBlockViewMode == "left" && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 4137 { 4138 Block facetsBlock = new Block 4139 { 4140 Id = "Facets", 4141 SortId = 30, 4142 Template = RenderProductListFacets() 4143 }; 4144 productListFacetsBlocksPage.Add("Navigation", facetsBlock); 4145 } 4146 4147 if (facetsBlockViewMode == "top" || Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet") 4148 { 4149 Block facetsBlock = new Block 4150 { 4151 Id = "Facets", 4152 SortId = 10, 4153 Template = RenderProductListTopFacets() 4154 }; 4155 productListFacetsBlocksPage.Add("ProductList", facetsBlock); 4156 } 4157 4158 Block facetSelections = new Block 4159 { 4160 Id = "FacetSelections", 4161 SortId = 20, 4162 Template = RenderFacetSelections() 4163 }; 4164 productListFacetsBlocksPage.Add("ProductList", facetSelections); 4165 4166 Block checkboxFacetTemplate = new Block 4167 { 4168 Id = "CheckboxFacet", 4169 SortId = 30, 4170 Template = RenderCheckboxFacets() 4171 }; 4172 productListFacetsBlocksPage.Add("BottomSnippets", checkboxFacetTemplate); 4173 4174 Block tagsFacetTemplate = new Block 4175 { 4176 Id = "TagsFacet", 4177 SortId = 40, 4178 Template = RenderTagsFacets() 4179 }; 4180 productListFacetsBlocksPage.Add("BottomSnippets", tagsFacetTemplate); 4181 4182 Block colorsFacetTemplate = new Block 4183 { 4184 Id = "ColorFacet", 4185 SortId = 50, 4186 Template = RenderColorFacets() 4187 }; 4188 productListFacetsBlocksPage.Add("BottomSnippets", colorsFacetTemplate); 4189 4190 Block selectedFilter = new Block 4191 { 4192 Id = "SelectedFilter", 4193 SortId = 60, 4194 Template = RenderSelectedFilter() 4195 }; 4196 productListFacetsBlocksPage.Add("BottomSnippets", selectedFilter); 4197 4198 Block selectedColorFilter = new Block 4199 { 4200 Id = "SelectedColorFilter", 4201 SortId = 70, 4202 Template = RenderSelectedColorFilter() 4203 }; 4204 productListFacetsBlocksPage.Add("BottomSnippets", selectedColorFilter); 4205 4206 Block resetFilters = new Block 4207 { 4208 Id = "ResetFilters", 4209 SortId = 80, 4210 Template = RenderResetFilters() 4211 }; 4212 productListFacetsBlocksPage.Add("BottomSnippets", resetFilters); 4213 } 4214 4215 @helper RenderFacetSelections() 4216 { 4217 @*This is part of a script template *@ 4218 <text> 4219 {{#if FacetSelections}} 4220 <div class="buttons-collection u-margin-bottom" id="selectedFacets"> 4221 {{#FacetSelections}} 4222 {{>(lookup . 'template')}} 4223 {{/FacetSelections}} 4224 </div> 4225 {{/if}} 4226 </text> 4227 } 4228 4229 @helper RenderProductListFacets() 4230 { 4231 @*This is part of a script template *@ 4232 <div class="u-margin-bottom--lg"> 4233 <h2 class="u-no-margin">@Translate("Filters")</h2> 4234 </div> 4235 4236 <input type="checkbox" id="CheckFacetGroups" class="js-remember-state u-hidden" data-expand="CheckFacetGroups" /> 4237 <div class="facets-container facets-container--left expandable--collapsed dw-mod" data-trigger="CheckFacetGroups"> 4238 {{#FacetGroups}} 4239 <input type="checkbox" id="OptionsGroup_{{name}}" class="expand-trigger js-remember-state" {{defaultState}} /> 4240 4241 <div class="expand-container facets-container__box dw-mod js-filter"> 4242 <label class="expand-container__btn facets-container__header dw-mod" for="OptionsGroup_{{name}}">{{name}}</label> 4243 <div class="expand-container__content dw-mod"> 4244 <div class="u-margin {{showFilter}}"> 4245 <input type="text" class="u-full-width u-no-margin" onkeyup="Filter.FilterItems(event)" placeholder="@Translate("Search")" /> 4246 </div> 4247 <div class="facets-container__list dw-mod"> 4248 {{#FacetOptions}} 4249 {{#ifCond template "===" "Checkboxes"}} 4250 {{>Checkboxes}} 4251 {{/ifCond}} 4252 {{#ifCond template "===" "Range"}} 4253 {{>Checkboxes}} 4254 {{/ifCond}} 4255 {{#ifCond template "===" "Weight"}} 4256 {{>Checkboxes}} 4257 {{/ifCond}} 4258 {{#ifCond template "===" "Tags"}} 4259 {{>Tags}} 4260 {{/ifCond}} 4261 {{#ifCond template "===" "Colors"}} 4262 {{>Colors}} 4263 {{/ifCond}} 4264 {{/FacetOptions}} 4265 <div class="u-hidden js-filter-not-found"> 4266 @Translate("Your search gave 0 results") 4267 </div> 4268 </div> 4269 </div> 4270 </div> 4271 {{/FacetGroups}} 4272 </div> 4273 <label for="CheckFacetGroups" class="btn btn--primary btn--full u-no-margin dw-mod js-expand-hide facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Select filters")</label> 4274 <label for="CheckFacetGroups" class="btn btn--primary btn--full u-no-margin dw-mod expandable--collapsed facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Close filters")</label> 4275 } 4276 4277 @helper RenderProductListTopFacets() 4278 { 4279 @*This is part of a script template *@ 4280 <input type="checkbox" id="CheckFacetGroups" class="js-remember-state u-hidden" data-expand="CheckFacetGroups" /> 4281 <div class="grid grid--external-bleed dw-mod expandable--collapsed facets-container facets-container--top u-margin-bottom" data-trigger="CheckFacetGroups"> 4282 {{#FacetGroups}} 4283 <div class="grid__col-lg-3 grid__col-md-3 grid__col-sm-4 grid__col-xs-12"> 4284 <input type="checkbox" id="OptionsGroup_{{counter}}" class="dropdown-trigger" /> 4285 <div class="dropdown dw-mod js-filter"> 4286 <label class="dropdown__header dropdown__btn dw-mod" for="OptionsGroup_{{counter}}">{{name}}</label> 4287 <div class="dropdown__content dropdown__content--padding dw-mod"> 4288 <div class="u-margin-bottom {{showFilter}}"> 4289 <input type="text" class="u-full-width u-no-margin" onkeyup="Filter.FilterItems(event)" placeholder="@Translate("Search")" /> 4290 </div> 4291 {{#FacetOptions}} 4292 {{#ifCond template "===" "Checkboxes"}} 4293 {{>Checkboxes}} 4294 {{/ifCond}} 4295 {{#ifCond template "===" "Range"}} 4296 {{>Checkboxes}} 4297 {{/ifCond}} 4298 {{#ifCond template "===" "Weight"}} 4299 {{>Checkboxes}} 4300 {{/ifCond}} 4301 {{#ifCond template "===" "Tags"}} 4302 {{>Tags}} 4303 {{/ifCond}} 4304 {{#ifCond template "===" "Colors"}} 4305 {{>Colors}} 4306 {{/ifCond}} 4307 {{/FacetOptions}} 4308 <div class="u-hidden js-filter-not-found"> 4309 @Translate("Your search gave 0 results") 4310 </div> 4311 </div> 4312 <label class="dropdown-trigger-off" for="OptionsGroup_{{counter}}"></label> 4313 </div> 4314 </div> 4315 {{/FacetGroups}} 4316 </div> 4317 <label for="CheckFacetGroups" class="btn btn--primary btn--full u-margin-bottom--lg dw-mod js-expand-hide facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Select filters")</label> 4318 <label for="CheckFacetGroups" class="btn btn--primary btn--full u-margin-bottom--lg dw-mod expandable--collapsed facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Close filters")</label> 4319 } 4320 4321 @helper RenderCheckboxFacets() 4322 { 4323 <script id="Checkboxes" type="text/x-template"> 4324 <input type="checkbox" class="{{selected}} checkbox-facet__checkbox form__control dw-mod" onclick="Facets.UpdateFacets(this);" id="{{queryParameter}}{{value}}" name="{{queryParameter}}" value="[{{value}}]" {{selected}} {{disabled}}> 4325 <label class="{{disabled}} checkbox-facet dw-mod" data-filter-value="{{label}}" for="{{queryParameter}}{{value}}"> 4326 <span class="checkbox-facet__label dw-mod">{{label}}</span> 4327 <span class="checkbox-facet__count dw-mod">({{count}})</span> 4328 </label> 4329 </script> 4330 } 4331 4332 @helper RenderTagsFacets() 4333 { 4334 <script id="Tags" type="text/x-template"> 4335 <button type="button" class="btn btn--tag {{selected}} {{disabled}} dw-mod" data-filter-value="{{label}}" data-check="{{selected}}" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" {{disabled}}> 4336 {{label}} <span class="facets-group__counter dw-mod">({{count}})</span> 4337 </button> 4338 </script> 4339 } 4340 4341 @helper RenderColorFacets() 4342 { 4343 <script id="Colors" type="text/x-template"> 4344 <button type="button" class="btn btn--colorbox u-margin-right {{selected}} {{disabled}} dw-mod" data-filter-value="{{label}}" style="background-color: {{value}}" title="{{label}}" data-check="{{selected}}" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" {{disabled}}></button> 4345 </script> 4346 } 4347 4348 @helper RenderSelectedFilter() 4349 { 4350 <script id="SelectedFilter" type="text/x-template"> 4351 <button type="button" class="btn btn--tag dw-mod" data-check="checked" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" title="@Translate("Remove filter")"> 4352 {{group}}: {{label}} <i class="fas fa-times"></i> 4353 </button> 4354 </script> 4355 } 4356 4357 @helper RenderSelectedColorFilter() 4358 { 4359 <script id="SelectedColorFilter" type="text/x-template"> 4360 <button type="button" class="btn btn--tag dw-mod" data-check="checked" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" title="@Translate("Remove filter")"> 4361 {{group}}: <div class="btn__colorbox dw-mod" style="background-color: {{value}}"></div> <i class="fas fa-times"></i> 4362 </button> 4363 </script> 4364 } 4365 4366 @helper RenderResetFilters() 4367 { 4368 <script id="ResetFilters" type="text/x-template"> 4369 <button type="button" class="btn btn--tag" onclick="Facets.ResetFacets();"> 4370 @Translate("Reset all filters") <i class="fas fa-redo"></i> 4371 </button> 4372 </script> 4373 } 4374 4375 4376 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4377 @using Dynamicweb.Core 4378 @using System 4379 @using System.Web 4380 @using System.Collections.Generic 4381 @using Dynamicweb.Rapido.Blocks 4382 4383 @{ 4384 BlocksPage productListMoreBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4385 4386 Block moreBlock = new Block 4387 { 4388 Id = "More", 4389 SortId = 40, 4390 Template = RenderListMore() 4391 }; 4392 4393 productListMoreBlocksPage.Add("ProductList", moreBlock); 4394 } 4395 4396 @helper RenderListMore() 4397 { 4398 @*This is part of a script template *@ 4399 string groupID = HttpContext.Current.Request.QueryString.Get("groupid"); 4400 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 4401 bool isFavoriteList = !string.IsNullOrEmpty(listId); 4402 string moreFeedFullUrl = GetGlobalValue("Global:Pageview.Url.Raw") + "&feed=true"; 4403 moreFeedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : ""; 4404 string columnCss = Pageview.Device.ToString() == "Mobile" ? "grid__col--bleed" : "grid__col--bleed-y"; 4405 4406 <div class="grid"> 4407 <div class="grid__col-12 @columnCss"> 4408 <button type="button" id="LoadMoreButton" class="btn btn--primary btn--full {{nextdisabled}} dw-mod" data-current="{{currentPage}}" data-page-size="{{pageSize}}" data-total="{{totalPages}}" data-container="ProductsContainer" data-feed-url="@moreFeedFullUrl&groupid=@groupID{{loadMoreFeedParams}}" onclick="LoadMore.Next(this)" {{nextdisabled}}>@Translate("Load") {{pageSizeText}} @Translate("more")</button> 4409 <button type="button" class="btn btn--clean" onclick="window.scroll(0, 0)">@Translate("Return to top")</button> 4410 </div> 4411 </div> 4412 } 4413 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4414 @using Dynamicweb.Core 4415 @using System 4416 @using System.Web 4417 @using System.Collections.Generic 4418 @using Dynamicweb.Rapido.Blocks 4419 @using Dynamicweb.Rapido.Blocks.Components 4420 @using Dynamicweb.Rapido.Blocks.Components.General 4421 4422 @{ 4423 BlocksPage productListBottomSnippetsPage = BlocksPage.GetBlockPage("ProductList"); 4424 4425 Block productListStickers = new Block 4426 { 4427 Id = "Stickers", 4428 SortId = 10, 4429 Template = RenderStickersTemplates() 4430 }; 4431 productListBottomSnippetsPage.Add("BottomSnippets", productListStickers); 4432 4433 Block productListUnits = new Block 4434 { 4435 Id = "Units", 4436 SortId = 20, 4437 Template = RenderUnitTemplates() 4438 }; 4439 productListBottomSnippetsPage.Add("BottomSnippets", productListUnits); 4440 4441 Block productListVariants = new Block 4442 { 4443 Id = "Variants", 4444 SortId = 30, 4445 Template = RenderVariantTemplates() 4446 }; 4447 productListBottomSnippetsPage.Add("BottomSnippets", productListVariants); 4448 4449 Block productListFavorites = new Block 4450 { 4451 Id = "Favorites", 4452 SortId = 40, 4453 Template = RenderFavoritesTemplates() 4454 }; 4455 productListBottomSnippetsPage.Add("BottomSnippets", productListFavorites); 4456 4457 Block productListPreRender = new Block 4458 { 4459 Id = "PreRenders", 4460 SortId = 50, 4461 Template = RenderPreRenderTemplates() 4462 }; 4463 productListBottomSnippetsPage.Add("BottomSnippets", productListPreRender); 4464 4465 Block productListInitializers = new Block 4466 { 4467 Id = "Initializers", 4468 SortId = 60, 4469 Template = RenderInitializers() 4470 }; 4471 productListBottomSnippetsPage.Add("BottomSnippets", productListInitializers); 4472 } 4473 4474 4475 @helper RenderFavoritesTemplates() 4476 { 4477 var selectedFavoriteIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "star"; 4478 string favoriteIcon = "fas fa-" + selectedFavoriteIcon; 4479 string favoriteOutlineIcon = "far fa-" + selectedFavoriteIcon; 4480 bool useFacebookPixel = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID")); 4481 string currentFavoriteListId = HttpContext.Current.Request.QueryString.Get("ListID"); 4482 4483 <script id="FavoriteTemplate" type="text/x-template"> 4484 <div class="favorites-list u-ta-left js-favorites-list"> 4485 @Render(new Button { 4486 CssClass = "u-no-margin js-favorite-btn", 4487 Icon = new Icon 4488 { 4489 Name = "{{#if isInAnyFavoriteList}}" + favoriteIcon + "{{else}}" + favoriteOutlineIcon + "{{/if}}", 4490 CssClass = "fa-1_5x", 4491 LabelPosition = IconLabelPosition.After 4492 }, 4493 ButtonLayout = ButtonLayout.LinkClean, 4494 ButtonType = ButtonType.Button, 4495 OnClick = "document.getElementById('FavoriteTrigger_{{id}}').checked = true" 4496 }) 4497 <input type="checkbox" id="FavoriteTrigger_{{id}}" class="dropdown-trigger" /> 4498 <div class="dropdown dropdown--absolute-position"> 4499 <div class="dropdown__content dropdown__content--show-left dropdown__content--padding u-w220px dw-mod"> 4500 <ul class="list list--clean dw-mod"> 4501 {{#FavoriteLists}} 4502 {{>FavoriteListItem}} 4503 {{/FavoriteLists}} 4504 </ul> 4505 </div> 4506 <label class="dropdown-trigger-off" for="FavoriteTrigger_{{id}}"></label> 4507 </div> 4508 </div> 4509 </script> 4510 4511 <script id="FavoriteListItem" type="text/x-template"> 4512 <li> 4513 @{ 4514 var button = new Button { 4515 CssClass = "list__link u-no-underline", 4516 OnClick = "toggleFavAction(this, event)", 4517 Icon = new Icon { Name = "{{#if isInFavoriteList}}" + favoriteIcon + "{{else}}" + favoriteOutlineIcon + "{{/if}}", LabelPosition = IconLabelPosition.After }, 4518 AltText = "{{#if isInFavoriteList}}" + Translate("Remove from") + " {{name}}{{else}}" + Translate("Add to") + " {{name}}{{/if}}", 4519 Title = "{{name}}", 4520 ButtonType = ButtonType.Button, 4521 ButtonLayout = ButtonLayout.LinkClean, 4522 ExtraAttributes = new Dictionary<string, string> 4523 { 4524 { "data-list-id", "{{listId}}" }, 4525 { "data-list-name", "{{name}}" }, 4526 { "data-remove-link", "{{removeLink}}" }, 4527 { "data-add-link", "{{addLink}}" }, 4528 { "data-is-in-list", "{{isInFavoriteList}}" }, 4529 4530 } 4531 }; 4532 if (useFacebookPixel) 4533 { 4534 button.ExtraAttributes.Add("data-facebook-object", "{{facebookPixelAddAction}}"); 4535 } 4536 } 4537 @Render(button) 4538 </li> 4539 </script> 4540 4541 <script> 4542 @if (!string.IsNullOrEmpty(currentFavoriteListId)) 4543 { 4544 <text> 4545 window.currentFavoriteListId = "@currentFavoriteListId"; 4546 </text> 4547 } 4548 function toggleFavAction(button, event) { 4549 if (button.getAttribute('data-add-link').indexOf('CCCreateNewList') > -1) { 4550 Scroll.SavePosition(event); 4551 @if (useFacebookPixel) 4552 { 4553 <text> 4554 fbq('track', 'AddToWishlist', JSON.parse(button.getAttribute('data-facebook-object'))); 4555 </text> 4556 } 4557 location.href = button.getAttribute('data-add-link'); 4558 return; 4559 } 4560 let isAdd = button.getAttribute('data-is-in-list') == "false"; 4561 Request.Fetch().get( 4562 isAdd ? button.getAttribute('data-add-link') : button.getAttribute('data-remove-link'), 4563 function (result) { 4564 button.querySelector('i').className = isAdd ? '@favoriteIcon' : '@favoriteOutlineIcon'; 4565 button.setAttribute('data-is-in-list', isAdd); 4566 button.setAttribute('title', (!isAdd ? '@Translate("Add to") ' : '@Translate("Remove from") ') + button.getAttribute('data-list-name')) 4567 let favList = button.closest('.js-favorites-list'); 4568 let favBtn = favList.querySelector('.js-favorite-btn i'); 4569 let isInAnyFavoriteList = favList.querySelector('[data-is-in-list=true]') != null; 4570 if (isInAnyFavoriteList) { 4571 favBtn.className = '@favoriteIcon' + ' fa-1_5x'; 4572 } else { 4573 favBtn.className = '@favoriteOutlineIcon' + ' fa-1_5x'; 4574 } 4575 @if (useFacebookPixel) 4576 { 4577 <text> 4578 if (isAdd) { 4579 fbq('track', 'AddToWishlist', JSON.parse(button.getAttribute('data-facebook-object'))); 4580 } 4581 </text> 4582 } 4583 if (window.currentFavoriteListId != null) { //if this page is favorite list 4584 let listId = button.getAttribute("data-list-id"); 4585 if (listId == window.currentFavoriteListId && !isAdd) { 4586 location.reload(); 4587 } 4588 } 4589 }, 4590 function () { 4591 console.error("FavoriteLists: Error in ToggleFavAction request"); 4592 }, 4593 false 4594 ); 4595 } 4596 </script> 4597 } 4598 4599 @helper RenderStickersTemplates() 4600 { 4601 <script id="StickersContainer" type="text/x-template"> 4602 <div class="stickers-container stickers-container--{{{convertStickerPositionToClassName Position}}} dw-mod"> 4603 {{#Stickers}} 4604 {{>Sticker}} 4605 {{/Stickers}} 4606 </div> 4607 </script> 4608 4609 <script id="Sticker" type="text/x-template"> 4610 <div class="stickers-container__tag {{CssClass}} dw-mod">{{Title}}</div> 4611 </script> 4612 4613 <script id="MiniSticker" type="text/x-template"> 4614 <div class="stickers-container__tag stickers-container__tag--micro {{CssClass}} dw-mod">{{Title}}</div> 4615 </script> 4616 } 4617 4618 @helper RenderUnitTemplates() 4619 { 4620 <script id="UnitOption" type="text/x-template"> 4621 <div class="dropdown__item dw-mod" onclick="HandlebarsBolt.UpdateContent(this.closest('.js-product').id, '{{link}}&feed=true&UnitID={{value}}')">{{name}}</div> 4622 </script> 4623 } 4624 4625 @helper RenderVariantTemplates() { 4626 <script id="VariantsTemplate" type="text/x-template"> 4627 {{#.}} 4628 <div> 4629 <div class="u-bold">{{name}}</div> 4630 <div> 4631 {{#VariantOptions}} 4632 {{>VariantOption}} 4633 {{/VariantOptions}} 4634 </div> 4635 </div> 4636 {{/.}} 4637 </script> 4638 4639 <script id="VariantOption" type="text/x-template"> 4640 {{#if color}} 4641 <button type="button" data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" class="btn btn--colorbox u-margin-right {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}} style="background-color: {{color}}"></button> 4642 {{else}} 4643 {{#if image}} 4644 <img data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" src="{{image}}" onclick="MatchVariants.SelectThis(event)" alt="{{name}}" title="{{name}}" class="btn btn--tag {{selected}} js-variant-option" data-check="{{selected}}" /> 4645 {{else}} 4646 <button type="button" data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" class="btn btn--tag {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}}>{{name}}</button> 4647 {{/if}} 4648 {{/if}} 4649 </script> 4650 4651 <script id="DropdownVariantsTemplate" type="text/x-template"> 4652 {{#.}} 4653 <div> 4654 <div class="u-bold">{{name}}</div> 4655 <select id="VariantSelector_{{id}}" class="u-full-width dw-mod" name="VariantSelector_{{id}}" onchange="MatchVariants.SelectOnChange(event)" > 4656 <option>@Translate("Choose")</option> 4657 {{#VariantOptions}} 4658 {{>DropdownVariantOption}} 4659 {{/VariantOptions}} 4660 </select> 4661 </div> 4662 {{/.}} 4663 </script> 4664 4665 <script id="DropdownVariantOption" type="text/x-template"> 4666 <option class="js-variant-option {{selected}}" id="{{groupId}}_{{variantId}}" value="{{groupId}}_{{variantId}}" data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" {{#if selected}}selected{{/if}} data-check="{{selected}}">{{name}}</option> 4667 </script> 4668 4669 <script id="StaticVariantsTemplate" type="text/x-template"> 4670 {{#.}} 4671 {{#if isFirstGroup}} 4672 <div> 4673 {{#VariantOptions}} 4674 {{>StaticVariantOption}} 4675 {{/VariantOptions}} 4676 </div> 4677 {{/if}} 4678 {{/.}} 4679 </script> 4680 4681 <script id="StaticVariantOption" type="text/x-template"> 4682 {{#if color}} 4683 <div class="static-variant static-variant--color dw-mod" style="background-color: {{color}}" title="{{name}}"></div> 4684 {{else}} 4685 <div class="static-variant dw-mod">{{name}} </div> 4686 {{/if}} 4687 </script> 4688 4689 <script id="VariantOptionImage" type="text/x-template"> 4690 <img data-variant-id="{{variantId}}" data-friends="{{friendsList}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" src="/Admin/Public/GetImage.ashx?width=100&amp;height=50&amp;crop=5&amp;Compression=75&amp;image=/Images/{{image}}" alt="{{name}}" title="{{name}}" class="btn btn--tag {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}} /> 4691 </script> 4692 } 4693 4694 @helper RenderPreRenderTemplates() { 4695 string facetsViewMode = !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode")) ? Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode").ToLower() : "left"; 4696 4697 <script id="ProductPreRenderContainer" type="text/x-template"> 4698 @if (facetsViewMode == "left" && Pageview.Device.ToString() != "Mobile") 4699 { 4700 <div class="grid__col-3"> 4701 <div class="pre-render-element pre-render-element--xs"></div> 4702 <div class="pre-render-element pre-render-element--md"></div> 4703 <div class="pre-render-element pre-render-element--md"></div> 4704 <div class="pre-render-element pre-render-element--md"></div> 4705 </div> 4706 } 4707 <div class="grid__col-auto"> 4708 <div class="pre-render-element pre-render-element--xs"></div> 4709 <div class="pre-render-element pre-render-element--lg"></div> 4710 <div class="pre-render-element pre-render-element--lg"></div> 4711 <div class="pre-render-element pre-render-element--lg"></div> 4712 <div class="pre-render-element pre-render-element--lg"></div> 4713 </div> 4714 </script> 4715 } 4716 4717 @helper RenderInitializers() { 4718 <script> 4719 document.addEventListener("DOMContentLoaded", function (event) { 4720 document.getElementById("productList").addEventListener('contentLoaded', function (e) { 4721 if (getTarget(e).id === "productList") { 4722 Search.Init(); 4723 Facets.Init("selectedFacets", "productList"); 4724 } 4725 }, false); 4726 4727 @{ 4728 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 4729 4730 if (useGoogleTagManager) 4731 { 4732 <text> 4733 Scroll.AddIsInViewportListener(".js-product-scroll-trigger", function (elem) { 4734 let googleImpression = JSON.parse(elem.getAttribute("data-params")); 4735 googleEnchantImpression(googleImpression); 4736 elem.classList.remove("js-product-scroll-trigger"); 4737 }); 4738 </text> 4739 } 4740 } 4741 4742 }); 4743 </script> 4744 } 4745 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4746 @using Dynamicweb.Core 4747 @using System 4748 @using System.Web 4749 @using System.Linq 4750 @using System.Collections.Generic 4751 @using Dynamicweb.Rapido.Blocks 4752 @using Dynamicweb.Rapido.Services 4753 4754 @functions { 4755 BlocksPage productListActionsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4756 } 4757 4758 @{ 4759 string actionsFavoriteListId = HttpContext.Current.Request.QueryString.Get("ListID"); 4760 bool actionsIsFavoriteList = !string.IsNullOrEmpty(actionsFavoriteListId); 4761 string actionsColumnSize = actionsIsFavoriteList ? "8" : "6"; 4762 4763 productListActionsBlocksPage.Add("ProductListHeader", new Block 4764 { 4765 Id = "Actions", 4766 SortId = 30, 4767 Template = RenderListActions(), 4768 Design = new Design 4769 { 4770 CssClass = "grid__col-md-6 grid__col-sm-" + actionsColumnSize + " grid--align-self-center" 4771 } 4772 }); 4773 4774 productListActionsBlocksPage.Add("BottomSnippets", new Block() { 4775 Id = "ListViewSelectListener", 4776 Template = RenderListViewSelectListener() 4777 }); 4778 4779 } 4780 4781 @helper RenderListActions() 4782 { 4783 @*This is part of a script template *@ 4784 4785 bool showSorting = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableSorting"); 4786 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 4787 bool isFavoriteList = !string.IsNullOrEmpty(listId); 4788 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fas fa-shopping-cart"; 4789 4790 List<Block> subBlocks = this.productListActionsBlocksPage.GetBlockListById("Views").OrderBy(item => item.SortId).ToList(); 4791 4792 <div class="buttons-collection buttons-collection--right"> 4793 @if (showSorting) 4794 { 4795 string dropdownCssClass = Pageview.Device.ToString() == "Mobile" ? "u-flex-grow--1" : ""; 4796 4797 <h5 class="u-inline-block">@Translate("Sort by")</h5> 4798 <input type="checkbox" id="ProductSort" class="dropdown-trigger" /> 4799 <div class="dropdown u-w150px u-inline-block @dropdownCssClass dw-mod"> 4800 <label class="dropdown__header dropdown__btn dropdown__btn--small dw-mod" for="ProductSort">{{selectedSort}}</label> 4801 <div class="dropdown__content dw-mod"> 4802 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: '', SortOrder: '' }, true);">@Translate("Default")</div> 4803 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Created', SortOrder: 'DESC'}, true);">@Translate("Newest")</div> 4804 @if (Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 4805 { 4806 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Price', SortOrder: 'ASC' }, true);">@Translate("Price low - high")</div> 4807 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Price', SortOrder: 'DESC' }, true);">@Translate("Price high - low")</div> 4808 } 4809 </div> 4810 <label class="dropdown-trigger-off" for="ProductSort"></label> 4811 </div> 4812 } 4813 4814 @if (subBlocks.Count > 1) 4815 { 4816 <div> 4817 @foreach (Block item in subBlocks) 4818 { 4819 <input type="radio" class="tag-btn-trigger" id="ListViewBtn_@item.Id" name="ViewBtnGroup"> 4820 <label for="ListViewBtn_@item.Id" class="btn btn--tag u-no-margin" onclick="HandlebarsBolt.UpdateTemplate('ProductsContainer', '@item.Id')"><i class="fas fa-@item.Name"></i></label> 4821 } 4822 </div> 4823 } 4824 4825 @if (isFavoriteList && Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 4826 { 4827 if (Pageview.Device.ToString() != "Mobile") 4828 { 4829 <button type="submit" class="btn btn--secondary btn--sm dw-mod">@Translate("Buy all") <i class="@cartIcon"></i></button> 4830 } 4831 else 4832 { 4833 <button type="submit" class="btn btn--secondary btn--full btn--sm dw-mod">@Translate("Buy all") <i class="@cartIcon"></i></button> 4834 } 4835 } 4836 </div> 4837 } 4838 4839 @helper RenderListViewSelectListener() 4840 { 4841 /* the same block code placed in ProductListFeed.cshtml */ 4842 Dictionary<string, bool> views = new Dictionary<string, bool>() 4843 { 4844 { "ProductItemContainer", Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableListView") }, 4845 { "ProductGridItemContainer", Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableGridView") }, 4846 { "ProductDetailsItemContainer", Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableDetailsView") } 4847 }; 4848 4849 string defaultView = Pageview.AreaSettings.GetItem("ProductList").GetList("DefaultListView") != null ? Pageview.AreaSettings.GetItem("ProductList").GetList("DefaultListView").SelectedValue : ""; 4850 4851 if (string.IsNullOrEmpty(defaultView) || !views[defaultView]) 4852 { 4853 defaultView = views.FirstOrDefault(x => x.Value).Key ?? "ProductItemContainer"; 4854 } 4855 4856 <script> 4857 let defaultTemplate = '@defaultView'; 4858 let container = 'productList'; 4859 let cookieName = 'ProductsContainerTemplate'; 4860 4861 document.addEventListener('DOMContentLoaded', function (event) { 4862 document.getElementById(container).addEventListener('contentLoaded', function () { 4863 let selectedMode = RememberState.GetCookie(cookieName); 4864 let element = document.getElementById('ListViewBtn_' + (selectedMode ? selectedMode : defaultTemplate)); 4865 if (element != null) { 4866 element.checked = true; 4867 } 4868 }, false); 4869 }); 4870 </script> 4871 } 4872 4873 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4874 @using Dynamicweb.Core 4875 @using System 4876 @using System.Web 4877 @using System.Collections.Generic 4878 @using Dynamicweb.Rapido.Blocks 4879 4880 @{ 4881 BlocksPage customBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4882 4883 } 4884 4885 4886 @if (productListNavigation.BlocksList.Count == 0) 4887 { 4888 productListNavigation.Design.RenderType = RenderType.Hide; 4889 } 4890 4891 <form name="multiForm" id="multiForm" method="post" onkeypress="return event.keyCode != 13;"> 4892 @* onkeypress is the fix for disabling submit form on Enter key from any field in product list *@ 4893 <input type="hidden" name="CartCmd" id="CartCmd" value="addMulti" /> 4894 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 4895 @RenderBlockList(productListPage.BlocksRoot.BlocksList) 4896 </form> 4897 4898 @helper RenderPageContainer() 4899 { 4900 List<Block> subBlocks = this.productListPage.GetBlockListById("PageContainer").OrderBy(item => item.SortId).ToList(); 4901 4902 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 4903 string feedFullUrl = pageUrl + "&feed=true"; 4904 feedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : ""; 4905 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "" : "u-padding"; 4906 4907 <div class="grid grid--align-content-start @smallDeviceCss js-handlebars-root" id="productList" data-template="ProductContainer" data-pre-render-template="ProductPreRenderContainer" data-json-feed="@feedFullUrl" data-preloader="overlay"></div> 4908 4909 <script id="ProductContainer" type="text/x-template"> 4910 {{#each .}} 4911 @RenderBlockList(subBlocks) 4912 {{else}} 4913 <div class="grid__col-12"> 4914 <h2 class="u-ta-center">@Translate("Your search gave 0 results")</h2> 4915 </div> 4916 {{/each}} 4917 </script> 4918 } 4919 4920 @helper RenderProductList() 4921 { 4922 @*This is part of a script template *@ 4923 4924 List<Block> subBlocks = productListPage.GetBlockListById("ProductList").OrderBy(item => item.SortId).ToList(); 4925 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "u-no-padding" : ""; 4926 string columnClass = "auto"; 4927 4928 if (productListPage.GetBlockListById("Navigation").Count == 0) 4929 { 4930 columnClass = "12"; 4931 } 4932 4933 <div class="grid__col-@columnClass @smallDeviceCss"> 4934 @RenderBlockList(subBlocks) 4935 </div> 4936 } 4937 4938 @helper RenderProductListTitle() 4939 { 4940 var header = new Heading { Title = "{{header}}", CssClass = "u-no-margin" }; 4941 4942 if (isFavoriteList) 4943 { 4944 var selectedFavoriteIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "star"; 4945 4946 header.Icon = new Icon { Prefix = "fas", Name = "fa-" + selectedFavoriteIcon }; 4947 } 4948 @Render(header) 4949 } 4950 4951 @helper RenderFavoriteListSearch() 4952 { 4953 string pageId = GetGlobalValue("Global:Page.ID"); 4954 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 4955 string feedFullUrl = pageUrl + "&feed=true"; 4956 string searchPlaceholder = Translate("Search favorite products"); 4957 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 4958 4959 <div class="typeahead u-color-inherit typeahead--favorites js-typeahead" data-page-size="10" id="FavoritesSearch" data-list-id="@favoriteListId" data-search-feed-id="@pageId&feed=true" data-result-page-id="@pageId"> 4960 <input type="text" class="typeahead-search-field u-no-margin u-full-width js-typeahead-search-field" placeholder="@searchPlaceholder" value="@searchValue"> 4961 <ul class="dropdown dropdown--absolute-position u-full-width js-handlebars-root js-typeahead-search-content u-min-w220px u-full-width dw-mod" id="FavoritesSearchContent" data-template="SearchProductsTemplate" data-json-feed="@feedFullUrl&ListID=@favoriteListId" data-init-onload="false" data-preloader="minimal"></ul> 4962 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn"><i class="fas fa-search"></i></button> 4963 </div> 4964 }
Cookies

This website uses cookies to track your behavior and to improve your experience on the site.