Error executing template "Designs/Rapido/_parsed/DynamicArticle.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_807e8bff61d146c5995898ad1a6d5c30.Execute() in F:\Website\rapidofull-20201103-files\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 8453
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 2 3 @using System.Web; 4 @using Dynamicweb.Frontend 5 @using Dynamicweb.Frontend.Devices 6 @using Dynamicweb.Extensibility 7 @using Dynamicweb.Content 8 @using Dynamicweb.Security 9 @using Dynamicweb.Core 10 @using System 11 @using System.Web 12 @using System.IO 13 @using Dynamicweb.Rapido.Blocks 14 @using System.Net 15 16 17 @functions { 18 BlocksPage masterPage = BlocksPage.GetBlockPage("Master"); 19 20 string getFontFamily(params string[] items) 21 { 22 var itemParent = Pageview.AreaSettings; 23 foreach (var item in items) 24 { 25 itemParent = itemParent.GetItem(item); 26 if (itemParent == null) 27 { 28 return null; 29 } 30 } 31 32 var googleFont = itemParent.GetGoogleFont("FontFamily"); 33 if (googleFont == null) 34 { 35 return null; 36 } 37 return googleFont.Family.Replace(" ", "+"); 38 } 39 } 40 41 @{ 42 Block root = new Block 43 { 44 Id = "Root", 45 SortId = 10, 46 BlocksList = new List<Block> 47 { 48 new Block { 49 Id = "Head", 50 SortId = 10, 51 SkipRenderBlocksList = true, 52 Template = RenderMasterHead(), 53 BlocksList = new List<Block> 54 { 55 new Block { 56 Id = "HeadMetadata", 57 SortId = 10, 58 Template = RenderMasterMetadata(), 59 }, 60 new Block { 61 Id = "HeadCss", 62 SortId = 20, 63 Template = RenderMasterCss(), 64 }, 65 new Block { 66 Id = "HeadManifest", 67 SortId = 30, 68 Template = RenderMasterManifest(), 69 } 70 } 71 }, 72 new Block { 73 Id = "Body", 74 SortId = 20, 75 SkipRenderBlocksList = true, 76 Template = RenderMasterBody(), 77 BlocksList = new List<Block> 78 { 79 new Block() 80 { 81 Id = "Master", 82 SortId = 10, 83 BlocksList = new List<Block> { 84 new Block { 85 Id = "MasterTopSnippets", 86 SortId = 10 87 }, 88 new Block { 89 Id = "MasterMain", 90 SortId = 20, 91 Template = RenderMain(), 92 SkipRenderBlocksList = true, 93 BlocksList = new List<Block> { 94 new Block { 95 Id = "MasterHeader", 96 SortId = 10, 97 Template = RenderMasterHeader(), 98 SkipRenderBlocksList = true 99 }, 100 new Block { 101 Id = "MasterPageContent", 102 SortId = 20, 103 Template = RenderPageContent() 104 } 105 } 106 }, 107 new Block { 108 Id = "MasterFooter", 109 SortId = 30 110 }, 111 new Block { 112 Id = "MasterReferences", 113 SortId = 40 114 }, 115 new Block { 116 Id = "MasterBottomSnippets", 117 SortId = 50, 118 BlocksList = new List<Block> { 119 new Block { 120 Id = "iOsTabletFix", 121 SortId = 10, 122 Template = RenderIosTabletFix() 123 } 124 } 125 } 126 } 127 } 128 } 129 } 130 } 131 }; 132 133 masterPage.Add(root); 134 } 135 136 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 137 @using System.Text.RegularExpressions 138 @using System.Collections.Generic 139 @using System.Reflection 140 @using System.Web 141 @using System.Web.UI.HtmlControls 142 @using Dynamicweb.Rapido.Blocks.Components 143 @using Dynamicweb.Rapido.Blocks.Components.Articles 144 @using Dynamicweb.Rapido.Blocks.Components.Documentation 145 @using Dynamicweb.Rapido.Blocks 146 147 148 @*--- START: Base block renderers ---*@ 149 150 @helper RenderBlockList(List<Block> blocks) 151 { 152 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 153 blocks = blocks.OrderBy(item => item.SortId).ToList(); 154 155 foreach (Block item in blocks) 156 { 157 if (debug) { 158 <!-- Block START: @item.Id --> 159 } 160 161 if (item.Design == null) 162 { 163 @RenderBlock(item) 164 } 165 else if (item.Design.RenderType == RenderType.None) { 166 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 167 168 <div class="@cssClass dw-mod"> 169 @RenderBlock(item) 170 </div> 171 } 172 else if (item.Design.RenderType != RenderType.Hide) 173 { 174 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 175 176 if (!item.SkipRenderBlocksList) { 177 if (item.Design.RenderType == RenderType.Row) 178 { 179 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 180 @RenderBlock(item) 181 </div> 182 } 183 184 if (item.Design.RenderType == RenderType.Column) 185 { 186 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 187 string size = item.Design.Size ?? "12"; 188 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 189 190 <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"> 191 @RenderBlock(item) 192 </div> 193 } 194 195 if (item.Design.RenderType == RenderType.Table) 196 { 197 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 198 @RenderBlock(item) 199 </table> 200 } 201 202 if (item.Design.RenderType == RenderType.TableRow) 203 { 204 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 205 @RenderBlock(item) 206 </tr> 207 } 208 209 if (item.Design.RenderType == RenderType.TableColumn) 210 { 211 <td class="@cssClass dw-mod" id="Block__@item.Id"> 212 @RenderBlock(item) 213 </td> 214 } 215 216 if (item.Design.RenderType == RenderType.CardHeader) 217 { 218 <div class="card-header @cssClass dw-mod"> 219 @RenderBlock(item) 220 </div> 221 } 222 223 if (item.Design.RenderType == RenderType.CardBody) 224 { 225 <div class="card @cssClass dw-mod"> 226 @RenderBlock(item) 227 </div> 228 } 229 230 if (item.Design.RenderType == RenderType.CardFooter) 231 { 232 <div class="card-footer @cssClass dw-mod"> 233 @RenderBlock(item) 234 </div> 235 } 236 } 237 else 238 { 239 @RenderBlock(item) 240 } 241 } 242 243 if (debug) { 244 <!-- Block END: @item.Id --> 245 } 246 } 247 } 248 249 @helper RenderBlock(Block item) 250 { 251 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 252 253 if (item.Template != null) 254 { 255 @BlocksPage.RenderTemplate(item.Template) 256 } 257 258 if (item.Component != null) 259 { 260 string customSufix = "Custom"; 261 string methodName = item.Component.HelperName; 262 263 ComponentBase[] methodParameters = new ComponentBase[1]; 264 methodParameters[0] = item.Component; 265 Type methodType = this.GetType(); 266 267 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 268 MethodInfo generalMethod = methodType.GetMethod(methodName); 269 270 try { 271 if (debug) { 272 <!-- Component: @methodName.Replace("Render", "") --> 273 } 274 @customMethod.Invoke(this, methodParameters).ToString(); 275 } catch { 276 try { 277 @generalMethod.Invoke(this, methodParameters).ToString(); 278 } catch(Exception ex) { 279 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 280 } 281 } 282 } 283 284 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 285 { 286 @RenderBlockList(item.BlocksList) 287 } 288 } 289 290 @*--- END: Base block renderers ---*@ 291 292 293 @* Include the components *@ 294 @using Dynamicweb.Rapido.Blocks.Components 295 @using Dynamicweb.Rapido.Blocks.Components.General 296 @using Dynamicweb.Rapido.Blocks 297 @using System.IO 298 299 @* Required *@ 300 @using Dynamicweb.Rapido.Blocks.Components 301 @using Dynamicweb.Rapido.Blocks.Components.General 302 @using Dynamicweb.Rapido.Blocks 303 304 305 @helper Render(ComponentBase component) 306 { 307 if (component != null) 308 { 309 @component.Render(this) 310 } 311 } 312 313 @* Components *@ 314 @using System.Reflection 315 @using Dynamicweb.Rapido.Blocks.Components.General 316 317 318 @* Component *@ 319 320 @helper RenderIcon(Icon settings) 321 { 322 if (settings != null) 323 { 324 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 325 326 if (settings.Name != null) 327 { 328 if (string.IsNullOrEmpty(settings.Label)) 329 { 330 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 331 } 332 else 333 { 334 if (settings.LabelPosition == IconLabelPosition.Before) 335 { 336 <div class="u-flex u-flex--align-items-center @settings.CssClass">@settings.Label <i class="@settings.Prefix @settings.Name u-margin-left" @color></i></div> 337 } 338 else 339 { 340 <div class="u-flex u-flex--align-items-center @settings.CssClass"><i class="@settings.Prefix @settings.Name u-margin-right--lg u-w20px" @color></i>@settings.Label</div> 341 } 342 } 343 } 344 else if (!string.IsNullOrEmpty(settings.Label)) 345 { 346 @settings.Label 347 } 348 } 349 } 350 @using System.Reflection 351 @using Dynamicweb.Rapido.Blocks.Components.General 352 @using Dynamicweb.Rapido.Blocks.Components 353 @using Dynamicweb.Core 354 355 @* Component *@ 356 357 @helper RenderButton(Button settings) 358 { 359 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 360 { 361 Dictionary<string, string> attributes = new Dictionary<string, string>(); 362 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 363 if (settings.Disabled) { 364 attributes.Add("disabled", "true"); 365 classList.Add("disabled"); 366 } 367 368 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 369 { 370 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 371 @RenderConfirmDialog(settings); 372 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 373 } 374 375 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 376 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 377 if (!string.IsNullOrEmpty(settings.AltText)) 378 { 379 attributes.Add("title", settings.AltText); 380 } 381 else if (!string.IsNullOrEmpty(settings.Title)) 382 { 383 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 384 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 385 attributes.Add("title", cleanTitle); 386 } 387 388 var onClickEvents = new List<string>(); 389 if (!string.IsNullOrEmpty(settings.OnClick)) 390 { 391 onClickEvents.Add(settings.OnClick); 392 } 393 if (!string.IsNullOrEmpty(settings.Href)) 394 { 395 onClickEvents.Add("location.href='" + settings.Href + "'"); 396 } 397 if (onClickEvents.Count > 0) 398 { 399 attributes.Add("onClick", string.Join(";", onClickEvents)); 400 } 401 402 if (settings.ButtonLayout != ButtonLayout.None) 403 { 404 classList.Add("btn"); 405 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 406 if (btnLayout == "linkclean") 407 { 408 btnLayout = "link-clean"; //fix 409 } 410 classList.Add("btn--" + btnLayout); 411 } 412 413 if (settings.Icon == null) 414 { 415 settings.Icon = new Icon(); 416 } 417 418 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 419 settings.Icon.Label = settings.Title; 420 421 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 422 423 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 424 } 425 } 426 427 @helper RenderConfirmDialog(Button settings) 428 { 429 Modal confirmDialog = new Modal { 430 Id = settings.Id, 431 Width = ModalWidth.Sm, 432 Heading = new Heading 433 { 434 Level = 2, 435 Title = settings.ConfirmTitle 436 }, 437 BodyText = settings.ConfirmText 438 }; 439 440 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 441 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 442 443 @Render(confirmDialog) 444 } 445 @using Dynamicweb.Rapido.Blocks.Components.General 446 @using Dynamicweb.Rapido.Blocks.Components 447 @using Dynamicweb.Core 448 449 @helper RenderDashboard(Dashboard settings) 450 { 451 var widgets = settings.GetWidgets(); 452 453 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 454 { 455 //set bg color for them 456 457 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 458 int r = Convert.ToInt16(color.R); 459 int g = Convert.ToInt16(color.G); 460 int b = Convert.ToInt16(color.B); 461 462 var count = widgets.Length; 463 var max = Math.Max(r, Math.Max(g, b)); 464 double step = 255.0 / (max * count); 465 var i = 0; 466 foreach (var widget in widgets) 467 { 468 i++; 469 470 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 471 widget.BackgroundColor = shade; 472 } 473 } 474 475 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 476 @foreach (var widget in widgets) 477 { 478 <div class="dashboard__widget"> 479 @Render(widget) 480 </div> 481 } 482 </div> 483 } 484 @using Dynamicweb.Rapido.Blocks.Components.General 485 @using Dynamicweb.Rapido.Blocks.Components 486 487 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 488 { 489 if (!string.IsNullOrEmpty(settings.Link)) 490 { 491 var backgroundStyles = ""; 492 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 493 { 494 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 495 } 496 497 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 498 <div class="u-center-middle u-color-light"> 499 @if (settings.Icon != null) 500 { 501 settings.Icon.CssClass += "widget__icon"; 502 @Render(settings.Icon) 503 } 504 <div class="widget__title">@settings.Title</div> 505 </div> 506 </a> 507 } 508 } 509 @using Dynamicweb.Rapido.Blocks.Components.General 510 @using Dynamicweb.Rapido.Blocks.Components 511 512 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 513 { 514 var backgroundStyles = ""; 515 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 516 { 517 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 518 } 519 520 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 521 <div class="u-center-middle u-color-light"> 522 @if (settings.Icon != null) 523 { 524 settings.Icon.CssClass += "widget__icon"; 525 @Render(settings.Icon) 526 } 527 <div class="widget__counter">@settings.Count</div> 528 <div class="widget__title">@settings.Title</div> 529 </div> 530 </div> 531 } 532 @using System.Reflection 533 @using Dynamicweb.Rapido.Blocks.Components.General 534 @using Dynamicweb.Rapido.Blocks.Components 535 @using Dynamicweb.Core 536 537 @* Component *@ 538 539 @helper RenderLink(Link settings) 540 { 541 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 542 { 543 Dictionary<string, string> attributes = new Dictionary<string, string>(); 544 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 545 if (settings.Disabled) 546 { 547 attributes.Add("disabled", "true"); 548 classList.Add("disabled"); 549 } 550 551 if (!string.IsNullOrEmpty(settings.AltText)) 552 { 553 attributes.Add("title", settings.AltText); 554 } 555 else if (!string.IsNullOrEmpty(settings.Title)) 556 { 557 attributes.Add("title", settings.Title); 558 } 559 560 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 561 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 562 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 563 attributes.Add("href", settings.Href); 564 565 if (settings.ButtonLayout != ButtonLayout.None) 566 { 567 classList.Add("btn"); 568 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 569 if (btnLayout == "linkclean") 570 { 571 btnLayout = "link-clean"; //fix 572 } 573 classList.Add("btn--" + btnLayout); 574 } 575 576 if (settings.Icon == null) 577 { 578 settings.Icon = new Icon(); 579 } 580 settings.Icon.Label = settings.Title; 581 582 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 583 { 584 settings.Rel = LinkRelType.Noopener; 585 } 586 if (settings.Target != LinkTargetType.None) 587 { 588 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 589 } 590 if (settings.Download) 591 { 592 attributes.Add("download", "true"); 593 } 594 if (settings.Rel != LinkRelType.None) 595 { 596 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 597 } 598 599 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 600 } 601 } 602 @using System.Reflection 603 @using Dynamicweb.Rapido.Blocks.Components 604 @using Dynamicweb.Rapido.Blocks.Components.General 605 @using Dynamicweb.Rapido.Blocks 606 607 608 @* Component *@ 609 610 @helper RenderRating(Rating settings) 611 { 612 if (settings.Score > 0) 613 { 614 int rating = settings.Score; 615 string iconType = "fa-star"; 616 617 switch (settings.Type.ToString()) { 618 case "Stars": 619 iconType = "fa-star"; 620 break; 621 case "Hearts": 622 iconType = "fa-heart"; 623 break; 624 case "Lemons": 625 iconType = "fa-lemon"; 626 break; 627 case "Bombs": 628 iconType = "fa-bomb"; 629 break; 630 } 631 632 <div class="u-ta-right"> 633 @for (int i = 0; i < settings.OutOf; i++) 634 { 635 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 636 } 637 </div> 638 } 639 } 640 @using System.Reflection 641 @using Dynamicweb.Rapido.Blocks.Components.General 642 @using Dynamicweb.Rapido.Blocks.Components 643 644 645 @* Component *@ 646 647 @helper RenderSelectFieldOption(SelectFieldOption settings) 648 { 649 Dictionary<string, string> attributes = new Dictionary<string, string>(); 650 if (settings.Checked) { attributes.Add("selected", "true"); } 651 if (settings.Disabled) { attributes.Add("disabled", "true"); } 652 if (settings.Value != null) { attributes.Add("value", settings.Value); } 653 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 654 655 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 656 } 657 @using System.Reflection 658 @using Dynamicweb.Rapido.Blocks.Components.General 659 @using Dynamicweb.Rapido.Blocks.Components 660 661 662 @* Component *@ 663 664 @helper RenderNavigation(Navigation settings) { 665 @RenderNavigation(new 666 { 667 id = settings.Id, 668 cssclass = settings.CssClass, 669 startLevel = settings.StartLevel, 670 endlevel = settings.EndLevel, 671 expandmode = settings.Expandmode, 672 sitemapmode = settings.SitemapMode, 673 template = settings.Template 674 }) 675 } 676 @using Dynamicweb.Rapido.Blocks.Components.General 677 @using Dynamicweb.Rapido.Blocks.Components 678 679 680 @* Component *@ 681 682 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 683 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 684 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 685 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 686 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 687 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 688 settings.SitemapMode = false; 689 690 @RenderNavigation(settings) 691 } 692 @using Dynamicweb.Rapido.Blocks.Components.General 693 @using Dynamicweb.Rapido.Blocks.Components 694 695 696 @* Component *@ 697 698 @helper RenderLeftNavigation(LeftNavigation settings) { 699 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 700 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 701 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 702 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 703 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 704 705 <div class="grid__cell"> 706 @RenderNavigation(settings) 707 </div> 708 } 709 @using System.Reflection 710 @using Dynamicweb.Rapido.Blocks.Components.General 711 @using Dynamicweb.Core 712 713 @* Component *@ 714 715 @helper RenderHeading(Heading settings) 716 { 717 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 718 { 719 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 720 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 721 722 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 723 if (!string.IsNullOrEmpty(settings.Link)) 724 { 725 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 726 } 727 else 728 { 729 if (settings.Icon == null) 730 { 731 settings.Icon = new Icon(); 732 } 733 settings.Icon.Label = settings.Title; 734 @Render(settings.Icon) 735 } 736 @("</" + tagName + ">"); 737 } 738 } 739 @using Dynamicweb.Rapido.Blocks.Components 740 @using Dynamicweb.Rapido.Blocks.Components.General 741 @using Dynamicweb.Rapido.Blocks 742 743 744 @* Component *@ 745 746 @helper RenderImage(Image settings) 747 { 748 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 749 { 750 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 751 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 752 753 if (settings.Caption != null) 754 { 755 @:<div> 756 } 757 758 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 759 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 760 761 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 762 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 763 @if (settings.Link != null) 764 { 765 <a href="@settings.Link"> 766 @RenderTheImage(settings) 767 </a> 768 } 769 else 770 { 771 @RenderTheImage(settings) 772 } 773 </div> 774 </div> 775 776 if (settings.Caption != null) 777 { 778 <span class="image-caption dw-mod">@settings.Caption</span> 779 @:</div> 780 } 781 } 782 else 783 { 784 if (settings.Caption != null) 785 { 786 @:<div> 787 } 788 if (!string.IsNullOrEmpty(settings.Link)) 789 { 790 <a href="@settings.Link"> 791 @RenderTheImage(settings) 792 </a> 793 } 794 else 795 { 796 @RenderTheImage(settings) 797 } 798 799 if (settings.Caption != null) 800 { 801 <span class="image-caption dw-mod">@settings.Caption</span> 802 @:</div> 803 } 804 } 805 } 806 807 @helper RenderTheImage(Image settings) 808 { 809 if (settings != null) 810 { 811 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 812 string placeholderImage = "/Files/Images/placeholder.gif"; 813 string imageEngine = "/Admin/Public/GetImage.ashx?"; 814 815 string imageStyle = ""; 816 817 switch (settings.Style) 818 { 819 case ImageStyle.Ball: 820 imageStyle = "grid__cell-img--ball"; 821 break; 822 823 case ImageStyle.Triangle: 824 imageStyle = "grid__cell-img--triangle"; 825 break; 826 } 827 828 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 829 { 830 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 831 832 if (settings.ImageDefault != null) 833 { 834 settings.ImageDefault.Height = settings.ImageDefault.Width; 835 } 836 if (settings.ImageMedium != null) 837 { 838 settings.ImageMedium.Height = settings.ImageMedium.Width; 839 } 840 if (settings.ImageSmall != null) 841 { 842 settings.ImageSmall.Height = settings.ImageSmall.Width; 843 } 844 } 845 846 string defaultImage = imageEngine; 847 string imageSmall = ""; 848 string imageMedium = ""; 849 850 if (settings.DisableImageEngine) 851 { 852 defaultImage = settings.Path; 853 } 854 else 855 { 856 if (settings.ImageDefault != null) 857 { 858 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 859 860 if (settings.Path.GetType() != typeof(string)) 861 { 862 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 863 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 864 } 865 else 866 { 867 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 868 } 869 870 defaultImage += "&AlternativeImage=" + alternativeImage; 871 } 872 873 if (settings.ImageSmall != null) 874 { 875 imageSmall = "data-src-small=\"" + imageEngine; 876 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 877 878 if (settings.Path.GetType() != typeof(string)) 879 { 880 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 881 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 882 } 883 else 884 { 885 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 886 } 887 888 imageSmall += "&alternativeImage=" + alternativeImage; 889 890 imageSmall += "\""; 891 } 892 893 if (settings.ImageMedium != null) 894 { 895 imageMedium = "data-src-medium=\"" + imageEngine; 896 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 897 898 if (settings.Path.GetType() != typeof(string)) 899 { 900 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 901 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 902 } 903 else 904 { 905 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 906 } 907 908 imageMedium += "&alternativeImage=" + alternativeImage; 909 910 imageMedium += "\""; 911 } 912 } 913 914 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 915 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 916 if (!string.IsNullOrEmpty(settings.Title)) 917 { 918 optionalAttributes.Add("alt", settings.Title); 919 optionalAttributes.Add("title", settings.Title); 920 } 921 922 if (settings.DisableLazyLoad) 923 { 924 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 925 } 926 else 927 { 928 <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) /> 929 } 930 } 931 } 932 @using System.Reflection 933 @using Dynamicweb.Rapido.Blocks.Components.General 934 @using Dynamicweb.Rapido.Blocks.Components 935 936 @* Component *@ 937 938 @helper RenderFileField(FileField settings) 939 { 940 var attributes = new Dictionary<string, string>(); 941 if (string.IsNullOrEmpty(settings.Id)) 942 { 943 settings.Id = Guid.NewGuid().ToString("N"); 944 } 945 946 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 947 if (settings.Disabled) { attributes.Add("disabled", "true"); } 948 if (settings.Required) { attributes.Add("required", "true"); } 949 if (settings.Multiple) { attributes.Add("multiple", "true"); } 950 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 951 if (string.IsNullOrEmpty(settings.ChooseFileText)) 952 { 953 settings.ChooseFileText = Translate("Choose file"); 954 } 955 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 956 { 957 settings.NoFilesChosenText = Translate("No files chosen..."); 958 } 959 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 960 961 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 962 963 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 964 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 965 966 attributes.Add("type", "file"); 967 if (settings.Value != null) { attributes.Add("value", settings.Value); } 968 settings.CssClass = "u-full-width " + settings.CssClass; 969 970 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 971 972 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 973 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 974 { 975 <div class="u-full-width"> 976 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 977 @if (settings.Link != null) { 978 <div class="u-pull--right"> 979 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 980 @Render(settings.Link) 981 </div> 982 } 983 </div> 984 985 } 986 987 @if (!string.IsNullOrEmpty(settings.HelpText)) 988 { 989 <small class="form__help-text">@settings.HelpText</small> 990 } 991 992 <div class="form__field-combi file-input u-no-margin dw-mod"> 993 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 994 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 995 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 996 @if (settings.UploadButton != null) 997 { 998 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 999 @Render(settings.UploadButton) 1000 } 1001 </div> 1002 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1003 </div> 1004 } 1005 @using System.Reflection 1006 @using Dynamicweb.Rapido.Blocks.Components.General 1007 @using Dynamicweb.Rapido.Blocks.Components 1008 @using Dynamicweb.Core 1009 @using System.Linq 1010 1011 @* Component *@ 1012 1013 @helper RenderDateTimeField(DateTimeField settings) 1014 { 1015 if (string.IsNullOrEmpty(settings.Id)) 1016 { 1017 settings.Id = Guid.NewGuid().ToString("N"); 1018 } 1019 1020 var textField = new TextField { 1021 Name = settings.Name, 1022 Id = settings.Id, 1023 Label = settings.Label, 1024 HelpText = settings.HelpText, 1025 Value = settings.Value, 1026 Disabled = settings.Disabled, 1027 Required = settings.Required, 1028 ErrorMessage = settings.ErrorMessage, 1029 CssClass = settings.CssClass, 1030 WrapperCssClass = settings.WrapperCssClass, 1031 OnChange = settings.OnChange, 1032 OnClick = settings.OnClick, 1033 Link = settings.Link, 1034 ExtraAttributes = settings.ExtraAttributes, 1035 // 1036 Placeholder = settings.Placeholder 1037 }; 1038 1039 @Render(textField) 1040 1041 List<string> jsAttributes = new List<string>(); 1042 1043 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 1044 1045 if (!string.IsNullOrEmpty(settings.DateFormat)) 1046 { 1047 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 1048 } 1049 if (!string.IsNullOrEmpty(settings.MinDate)) 1050 { 1051 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 1052 } 1053 if (!string.IsNullOrEmpty(settings.MaxDate)) 1054 { 1055 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 1056 } 1057 if (settings.IsInline) 1058 { 1059 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1060 } 1061 if (settings.EnableTime) 1062 { 1063 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1064 } 1065 if (settings.EnableWeekNumbers) 1066 { 1067 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1068 } 1069 1070 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1071 1072 <script> 1073 document.addEventListener("DOMContentLoaded", function () { 1074 flatpickr("#@textField.Id", { 1075 @string.Join(",", jsAttributes) 1076 }); 1077 }); 1078 </script> 1079 } 1080 @using System.Reflection 1081 @using Dynamicweb.Rapido.Blocks.Components.General 1082 @using Dynamicweb.Rapido.Blocks.Components 1083 1084 @* Component *@ 1085 1086 @helper RenderTextField(TextField settings) 1087 { 1088 var attributes = new Dictionary<string, string>(); 1089 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1090 { 1091 settings.Id = Guid.NewGuid().ToString("N"); 1092 } 1093 1094 /*base settings*/ 1095 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1096 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1097 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1098 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1099 if (settings.Required) { attributes.Add("required", "true"); } 1100 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1101 /*end*/ 1102 1103 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1104 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1105 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1106 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1107 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1108 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1109 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1110 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1111 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1112 1113 settings.CssClass = "u-full-width " + settings.CssClass; 1114 1115 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1116 1117 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1118 1119 string noMargin = "u-no-margin"; 1120 if (!settings.ReadOnly) { 1121 noMargin = ""; 1122 } 1123 1124 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1125 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1126 { 1127 <div class="u-full-width"> 1128 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1129 @if (settings.Link != null) { 1130 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1131 1132 <div class="u-pull--right"> 1133 @Render(settings.Link) 1134 </div> 1135 } 1136 </div> 1137 1138 } 1139 1140 @if (!string.IsNullOrEmpty(settings.HelpText)) 1141 { 1142 <small class="form__help-text">@settings.HelpText</small> 1143 } 1144 1145 @if (settings.ActionButton != null) 1146 { 1147 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1148 <div class="form__field-combi u-no-margin dw-mod"> 1149 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1150 @Render(settings.ActionButton) 1151 </div> 1152 } 1153 else 1154 { 1155 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1156 } 1157 1158 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1159 </div> 1160 } 1161 @using System.Reflection 1162 @using Dynamicweb.Rapido.Blocks.Components.General 1163 @using Dynamicweb.Rapido.Blocks.Components 1164 1165 @* Component *@ 1166 1167 @helper RenderNumberField(NumberField settings) 1168 { 1169 var attributes = new Dictionary<string, string>(); 1170 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1171 { 1172 settings.Id = Guid.NewGuid().ToString("N"); 1173 } 1174 1175 /*base settings*/ 1176 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1177 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1178 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1179 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1180 if (settings.Required) { attributes.Add("required", "true"); } 1181 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1182 /*end*/ 1183 1184 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1185 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1186 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1187 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1188 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1189 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1190 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1191 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1192 attributes.Add("type", "number"); 1193 1194 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1195 1196 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1197 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1198 { 1199 <div class="u-full-width"> 1200 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1201 @if (settings.Link != null) { 1202 <div class="u-pull--right"> 1203 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1204 @Render(settings.Link) 1205 </div> 1206 } 1207 </div> 1208 1209 } 1210 1211 @if (!string.IsNullOrEmpty(settings.HelpText)) 1212 { 1213 <small class="form__help-text">@settings.HelpText</small> 1214 } 1215 1216 @if (settings.ActionButton != null) 1217 { 1218 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1219 <div class="form__field-combi u-no-margin dw-mod"> 1220 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1221 @Render(settings.ActionButton) 1222 </div> 1223 } 1224 else 1225 { 1226 <div class="form__field-combi u-no-margin dw-mod"> 1227 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1228 </div> 1229 } 1230 1231 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1232 </div> 1233 } 1234 @using System.Reflection 1235 @using Dynamicweb.Rapido.Blocks.Components.General 1236 @using Dynamicweb.Rapido.Blocks.Components 1237 1238 1239 @* Component *@ 1240 1241 @helper RenderTextareaField(TextareaField settings) 1242 { 1243 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1244 string id = settings.Id; 1245 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1246 { 1247 id = Guid.NewGuid().ToString("N"); 1248 } 1249 1250 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1251 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1252 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1253 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1254 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1255 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1256 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1257 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1258 if (settings.Required) { attributes.Add("required", "true"); } 1259 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1260 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1261 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1262 attributes.Add("name", settings.Name); 1263 1264 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1265 1266 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1267 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1268 { 1269 <div class="u-full-width"> 1270 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1271 @if (settings.Link != null) { 1272 <div class="u-pull--right"> 1273 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1274 @Render(settings.Link) 1275 </div> 1276 } 1277 </div> 1278 } 1279 1280 @if (!string.IsNullOrEmpty(settings.HelpText)) 1281 { 1282 <small class="form__help-text">@settings.HelpText</small> 1283 } 1284 1285 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1286 1287 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1288 </div> 1289 } 1290 @using System.Reflection 1291 @using Dynamicweb.Rapido.Blocks.Components.General 1292 @using Dynamicweb.Rapido.Blocks.Components 1293 1294 1295 @* Component *@ 1296 1297 @helper RenderHiddenField(HiddenField settings) { 1298 var attributes = new Dictionary<string, string>(); 1299 attributes.Add("type", "hidden"); 1300 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1301 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1302 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1303 1304 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1305 } 1306 @using System.Reflection 1307 @using Dynamicweb.Rapido.Blocks.Components.General 1308 @using Dynamicweb.Rapido.Blocks.Components 1309 1310 @* Component *@ 1311 1312 @helper RenderCheckboxField(CheckboxField settings) 1313 { 1314 var attributes = new Dictionary<string, string>(); 1315 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1316 { 1317 settings.Id = Guid.NewGuid().ToString("N"); 1318 } 1319 1320 /*base settings*/ 1321 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1322 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1323 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1324 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1325 if (settings.Required) { attributes.Add("required", "true"); } 1326 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1327 /*end*/ 1328 1329 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1330 1331 attributes.Add("type", "checkbox"); 1332 if (settings.Checked) { attributes.Add("checked", "true"); } 1333 settings.CssClass = "form__control " + settings.CssClass; 1334 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1335 1336 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1337 1338 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1339 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1340 @if (!string.IsNullOrEmpty(settings.Label)) 1341 { 1342 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1343 } 1344 1345 @if (settings.Link != null) { 1346 <span> 1347 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1348 @Render(settings.Link) 1349 </span> 1350 } 1351 1352 @if (!string.IsNullOrEmpty(settings.HelpText)) 1353 { 1354 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1355 } 1356 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1357 </div> 1358 } 1359 @using System.Reflection 1360 @using Dynamicweb.Rapido.Blocks.Components.General 1361 @using Dynamicweb.Rapido.Blocks.Components 1362 1363 1364 @* Component *@ 1365 1366 @helper RenderCheckboxListField(CheckboxListField settings) 1367 { 1368 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1369 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1370 { 1371 <div class="u-full-width"> 1372 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1373 @if (settings.Link != null) { 1374 <div class="u-pull--right"> 1375 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1376 @Render(settings.Link) 1377 </div> 1378 } 1379 </div> 1380 1381 } 1382 1383 <div class="u-pull--left"> 1384 @if (!string.IsNullOrEmpty(settings.HelpText)) 1385 { 1386 <small class="form__help-text">@settings.HelpText</small> 1387 } 1388 1389 @foreach (var item in settings.Options) 1390 { 1391 if (settings.Required) 1392 { 1393 item.Required = true; 1394 } 1395 if (settings.Disabled) 1396 { 1397 item.Disabled = true; 1398 } 1399 if (!string.IsNullOrEmpty(settings.Name)) 1400 { 1401 item.Name = settings.Name; 1402 } 1403 if (!string.IsNullOrEmpty(settings.CssClass)) 1404 { 1405 item.CssClass += settings.CssClass; 1406 } 1407 1408 /* value is not supported */ 1409 1410 if (!string.IsNullOrEmpty(settings.OnClick)) 1411 { 1412 item.OnClick += settings.OnClick; 1413 } 1414 if (!string.IsNullOrEmpty(settings.OnChange)) 1415 { 1416 item.OnChange += settings.OnChange; 1417 } 1418 @Render(item) 1419 } 1420 1421 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1422 </div> 1423 1424 </div> 1425 } 1426 @using Dynamicweb.Rapido.Blocks.Components.General 1427 1428 @* Component *@ 1429 1430 @helper RenderSearch(Search settings) 1431 { 1432 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1433 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1434 1435 if (string.IsNullOrEmpty(settings.Id)) 1436 { 1437 settings.Id = Guid.NewGuid().ToString("N"); 1438 } 1439 1440 var resultAttributes = new Dictionary<string, string>(); 1441 1442 if (settings.PageSize != 0) 1443 { 1444 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1445 } 1446 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1447 { 1448 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1449 if (!string.IsNullOrEmpty(groupValue)) 1450 { 1451 resultAttributes.Add("data-selected-group", groupValue); 1452 } 1453 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1454 { 1455 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1456 } 1457 } 1458 resultAttributes.Add("data-force-init", "true"); 1459 if (settings.GoToFirstSearchResultOnEnter) 1460 { 1461 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1462 } 1463 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1464 { 1465 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1466 } 1467 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1468 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1469 1470 if (settings.SecondSearchData != null) 1471 { 1472 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1473 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1474 } 1475 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1476 { 1477 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1478 } 1479 1480 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1481 1482 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1483 1484 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1485 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1486 { 1487 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1488 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1489 } 1490 1491 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1492 1493 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1494 @if (settings.SecondSearchData != null) 1495 { 1496 <div class="search__column search__column--products dw-mod"> 1497 <div class="search__column-header dw-mod">@Translate("Products")</div> 1498 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1499 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1500 { 1501 @Render(new Link { 1502 Title = Translate("View all"), 1503 CssClass = "js-view-all-button u-margin", 1504 Href = settings.SearchData.ResultsPageUrl 1505 }); 1506 } 1507 </div> 1508 <div class="search__column search__column--pages dw-mod"> 1509 <div class="search__column-header">@Translate("Pages")</div> 1510 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1511 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1512 { 1513 @Render(new Link 1514 { 1515 Title = Translate("View all"), 1516 CssClass = "js-view-all-button u-margin", 1517 Href = settings.SecondSearchData.ResultsPageUrl 1518 }); 1519 } 1520 </div> 1521 } 1522 else 1523 { 1524 <div class="search__column search__column--only dw-mod"> 1525 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1526 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1527 { 1528 @Render(new Link { 1529 Title = Translate("View all"), 1530 CssClass = "js-view-all-button u-margin", 1531 Href = settings.SearchData.ResultsPageUrl 1532 }); 1533 } 1534 </div> 1535 } 1536 </div> 1537 1538 @if (settings.SearchButton != null) 1539 { 1540 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1541 if (settings.RenderDefaultSearchIcon) 1542 { 1543 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1544 } 1545 @Render(settings.SearchButton); 1546 } 1547 </div> 1548 } 1549 @using System.Reflection 1550 @using Dynamicweb.Rapido.Blocks.Components.General 1551 @using Dynamicweb.Rapido.Blocks.Components 1552 1553 1554 @* Component *@ 1555 1556 @helper RenderSelectField(SelectField settings) 1557 { 1558 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1559 { 1560 settings.Id = Guid.NewGuid().ToString("N"); 1561 } 1562 1563 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1564 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1565 { 1566 <div class="u-full-width"> 1567 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1568 @if (settings.Link != null) { 1569 <div class="u-pull--right"> 1570 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1571 @Render(settings.Link) 1572 </div> 1573 } 1574 </div> 1575 } 1576 1577 @if (!string.IsNullOrEmpty(settings.HelpText)) 1578 { 1579 <small class="form__help-text">@settings.HelpText</small> 1580 } 1581 1582 @if (settings.ActionButton != null) 1583 { 1584 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1585 <div class="form__field-combi u-no-margin dw-mod"> 1586 @RenderSelectBase(settings) 1587 @Render(settings.ActionButton) 1588 </div> 1589 } 1590 else 1591 { 1592 @RenderSelectBase(settings) 1593 } 1594 1595 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1596 </div> 1597 } 1598 1599 @helper RenderSelectBase(SelectField settings) 1600 { 1601 var attributes = new Dictionary<string, string>(); 1602 1603 /*base settings*/ 1604 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1605 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1606 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1607 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1608 if (settings.Required) { attributes.Add("required", "true"); } 1609 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1610 /*end*/ 1611 1612 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1613 1614 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1615 @if (settings.Default != null) 1616 { 1617 @Render(settings.Default) 1618 } 1619 1620 @foreach (var item in settings.Options) 1621 { 1622 if (settings.Value != null) { 1623 item.Checked = item.Value == settings.Value; 1624 } 1625 @Render(item) 1626 } 1627 </select> 1628 } 1629 @using System.Reflection 1630 @using Dynamicweb.Rapido.Blocks.Components.General 1631 @using Dynamicweb.Rapido.Blocks.Components 1632 1633 @* Component *@ 1634 1635 @helper RenderRadioButtonField(RadioButtonField settings) 1636 { 1637 var attributes = new Dictionary<string, string>(); 1638 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1639 { 1640 settings.Id = Guid.NewGuid().ToString("N"); 1641 } 1642 1643 /*base settings*/ 1644 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1645 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1646 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1647 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1648 if (settings.Required) { attributes.Add("required", "true"); } 1649 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1650 /*end*/ 1651 1652 attributes.Add("type", "radio"); 1653 if (settings.Checked) { attributes.Add("checked", "true"); } 1654 settings.CssClass = "form__control " + settings.CssClass; 1655 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1656 1657 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1658 1659 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1660 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1661 @if (!string.IsNullOrEmpty(settings.Label)) 1662 { 1663 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1664 } 1665 @if (!string.IsNullOrEmpty(settings.HelpText)) 1666 { 1667 <small class="form__help-text">@settings.HelpText</small> 1668 } 1669 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1670 </div> 1671 } 1672 @using System.Reflection 1673 @using Dynamicweb.Rapido.Blocks.Components.General 1674 @using Dynamicweb.Rapido.Blocks.Components 1675 1676 1677 @* Component *@ 1678 1679 @helper RenderRadioButtonListField(RadioButtonListField settings) 1680 { 1681 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1682 1683 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1684 @if (!string.IsNullOrEmpty(settings.Label)) 1685 { 1686 <label>@settings.Label</label> 1687 } 1688 @if (!string.IsNullOrEmpty(settings.HelpText)) 1689 { 1690 <small class="form__help-text">@settings.HelpText</small> 1691 } 1692 1693 @foreach (var item in settings.Options) 1694 { 1695 if (settings.Required) 1696 { 1697 item.Required = true; 1698 } 1699 if (settings.Disabled) 1700 { 1701 item.Disabled = true; 1702 } 1703 if (!string.IsNullOrEmpty(settings.Name)) 1704 { 1705 item.Name = settings.Name; 1706 } 1707 if (settings.Value != null && settings.Value == item.Value) 1708 { 1709 item.Checked = true; 1710 } 1711 if (!string.IsNullOrEmpty(settings.OnClick)) 1712 { 1713 item.OnClick += settings.OnClick; 1714 } 1715 if (!string.IsNullOrEmpty(settings.OnChange)) 1716 { 1717 item.OnChange += settings.OnChange; 1718 } 1719 if (!string.IsNullOrEmpty(settings.CssClass)) 1720 { 1721 item.CssClass += settings.CssClass; 1722 } 1723 @Render(item) 1724 } 1725 1726 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1727 </div> 1728 } 1729 @using System.Reflection 1730 @using Dynamicweb.Rapido.Blocks.Components.General 1731 @using Dynamicweb.Rapido.Blocks.Components 1732 1733 1734 @* Component *@ 1735 1736 @helper RenderNotificationMessage(NotificationMessage settings) 1737 { 1738 if (!string.IsNullOrEmpty(settings.Message)) 1739 { 1740 var attributes = new Dictionary<string, string>(); 1741 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1742 1743 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1744 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1745 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1746 1747 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1748 @if (settings.Icon != null) { 1749 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1750 @Render(settings.Icon) 1751 } else { 1752 @settings.Message 1753 } 1754 </div> 1755 } 1756 } 1757 @using Dynamicweb.Rapido.Blocks.Components.General 1758 1759 1760 @* Component *@ 1761 1762 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1763 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1764 1765 <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> 1766 @if (settings.SubBlocks != null) { 1767 @RenderBlockList(settings.SubBlocks) 1768 } 1769 </div> 1770 } 1771 @using System.Reflection 1772 @using Dynamicweb.Rapido.Blocks.Components.General 1773 @using Dynamicweb.Rapido.Blocks.Components 1774 @using System.Text.RegularExpressions 1775 1776 1777 @* Component *@ 1778 1779 @helper RenderSticker(Sticker settings) { 1780 if (!String.IsNullOrEmpty(settings.Title)) { 1781 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1782 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1783 1784 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1785 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1786 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1787 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1788 optionalAttributes.Add("style", styleTag); 1789 } 1790 1791 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1792 } 1793 } 1794 1795 @using System.Reflection 1796 @using Dynamicweb.Rapido.Blocks.Components.General 1797 @using Dynamicweb.Rapido.Blocks.Components 1798 1799 1800 @* Component *@ 1801 1802 @helper RenderStickersCollection(StickersCollection settings) 1803 { 1804 if (settings.Stickers.Count > 0) 1805 { 1806 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1807 1808 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1809 @foreach (Sticker sticker in settings.Stickers) 1810 { 1811 @Render(sticker) 1812 } 1813 </div> 1814 } 1815 } 1816 1817 @using Dynamicweb.Rapido.Blocks.Components.General 1818 1819 1820 @* Component *@ 1821 1822 @helper RenderForm(Form settings) { 1823 if (settings != null) 1824 { 1825 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1826 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1827 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1828 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1829 var enctypes = new Dictionary<string, string> 1830 { 1831 { "multipart", "multipart/form-data" }, 1832 { "text", "text/plain" }, 1833 { "application", "application/x-www-form-urlencoded" } 1834 }; 1835 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1836 optionalAttributes.Add("method", settings.Method.ToString()); 1837 1838 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1839 { 1840 @settings.FormStartMarkup 1841 } 1842 else 1843 { 1844 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1845 } 1846 1847 foreach (var field in settings.GetFields()) 1848 { 1849 @Render(field) 1850 } 1851 1852 @:</form> 1853 } 1854 } 1855 @using System.Reflection 1856 @using Dynamicweb.Rapido.Blocks.Components.General 1857 @using Dynamicweb.Rapido.Blocks.Components 1858 1859 1860 @* Component *@ 1861 1862 @helper RenderText(Text settings) 1863 { 1864 @settings.Content 1865 } 1866 @using System.Reflection 1867 @using Dynamicweb.Rapido.Blocks.Components.General 1868 @using Dynamicweb.Rapido.Blocks.Components 1869 1870 1871 @* Component *@ 1872 1873 @helper RenderContentModule(ContentModule settings) { 1874 if (!string.IsNullOrEmpty(settings.Content)) 1875 { 1876 @settings.Content 1877 } 1878 } 1879 @using System.Reflection 1880 @using Dynamicweb.Rapido.Blocks.Components.General 1881 @using Dynamicweb.Rapido.Blocks.Components 1882 1883 1884 @* Component *@ 1885 1886 @helper RenderModal(Modal settings) { 1887 if (settings != null) 1888 { 1889 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1890 1891 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1892 1893 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1894 1895 <div class="modal-container"> 1896 @if (!settings.DisableDarkOverlay) 1897 { 1898 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1899 } 1900 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1901 @if (settings.Heading != null) 1902 { 1903 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1904 { 1905 <div class="modal__header"> 1906 @Render(settings.Heading) 1907 </div> 1908 } 1909 } 1910 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1911 @if (!string.IsNullOrEmpty(settings.BodyText)) 1912 { 1913 @settings.BodyText 1914 } 1915 @if (settings.BodyTemplate != null) 1916 { 1917 @settings.BodyTemplate 1918 } 1919 @{ 1920 var actions = settings.GetActions(); 1921 } 1922 </div> 1923 @if (actions.Length > 0) 1924 { 1925 <div class="modal__footer"> 1926 @foreach (var action in actions) 1927 { 1928 if (Pageview.Device.ToString() != "Mobile") { 1929 action.CssClass += " u-no-margin"; 1930 } else { 1931 action.CssClass += " u-full-width u-margin-bottom"; 1932 } 1933 1934 @Render(action) 1935 } 1936 </div> 1937 } 1938 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1939 </div> 1940 </div> 1941 } 1942 } 1943 @using Dynamicweb.Rapido.Blocks.Components.General 1944 1945 @* Component *@ 1946 1947 @helper RenderMediaListItem(MediaListItem settings) 1948 { 1949 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1950 @if (!string.IsNullOrEmpty(settings.Label)) 1951 { 1952 if (!string.IsNullOrEmpty(settings.Link)) 1953 { 1954 @Render(new Link 1955 { 1956 Href = settings.Link, 1957 CssClass = "media-list-item__sticker dw-mod", 1958 ButtonLayout = ButtonLayout.None, 1959 Title = settings.Label, 1960 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1961 }) 1962 } 1963 else if (!string.IsNullOrEmpty(settings.OnClick)) 1964 { 1965 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1966 <span class="u-uppercase">@settings.Label</span> 1967 </span> 1968 } 1969 else 1970 { 1971 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1972 <span class="u-uppercase">@settings.Label</span> 1973 </span> 1974 } 1975 } 1976 <div class="media-list-item__wrap"> 1977 <div class="media-list-item__info dw-mod"> 1978 <div class="media-list-item__header dw-mod"> 1979 @if (!string.IsNullOrEmpty(settings.Title)) 1980 { 1981 if (!string.IsNullOrEmpty(settings.Link)) 1982 { 1983 @Render(new Link 1984 { 1985 Href = settings.Link, 1986 CssClass = "media-list-item__name dw-mod", 1987 ButtonLayout = ButtonLayout.None, 1988 Title = settings.Title, 1989 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1990 }) 1991 } 1992 else if (!string.IsNullOrEmpty(settings.OnClick)) 1993 { 1994 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1995 } 1996 else 1997 { 1998 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1999 } 2000 } 2001 2002 @if (!string.IsNullOrEmpty(settings.Status)) 2003 { 2004 <div class="media-list-item__state dw-mod">@settings.Status</div> 2005 } 2006 </div> 2007 @{ 2008 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 2009 } 2010 2011 @Render(settings.InfoTable) 2012 </div> 2013 <div class="media-list-item__actions dw-mod"> 2014 <div class="media-list-item__actions-list dw-mod"> 2015 @{ 2016 var actions = settings.GetActions(); 2017 2018 foreach (ButtonBase action in actions) 2019 { 2020 action.ButtonLayout = ButtonLayout.None; 2021 action.CssClass += " media-list-item__action link"; 2022 2023 @Render(action) 2024 } 2025 } 2026 </div> 2027 2028 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 2029 { 2030 settings.SelectButton.CssClass += " u-no-margin"; 2031 2032 <div class="media-list-item__action-button"> 2033 @Render(settings.SelectButton) 2034 </div> 2035 } 2036 </div> 2037 </div> 2038 </div> 2039 } 2040 @using Dynamicweb.Rapido.Blocks.Components.General 2041 @using Dynamicweb.Rapido.Blocks.Components 2042 2043 @helper RenderTable(Table settings) 2044 { 2045 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2046 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2047 2048 var enumToClasses = new Dictionary<TableDesign, string> 2049 { 2050 { TableDesign.Clean, "table--clean" }, 2051 { TableDesign.Bordered, "table--bordered" }, 2052 { TableDesign.Striped, "table--striped" }, 2053 { TableDesign.Hover, "table--hover" }, 2054 { TableDesign.Compact, "table--compact" }, 2055 { TableDesign.Condensed, "table--condensed" }, 2056 { TableDesign.NoTopBorder, "table--no-top-border" } 2057 }; 2058 string tableDesignClass = ""; 2059 if (settings.Design != TableDesign.None) 2060 { 2061 tableDesignClass = enumToClasses[settings.Design]; 2062 } 2063 2064 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 2065 2066 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2067 2068 <table @ComponentMethods.AddAttributes(resultAttributes)> 2069 @if (settings.Header != null) 2070 { 2071 <thead> 2072 @Render(settings.Header) 2073 </thead> 2074 } 2075 <tbody> 2076 @foreach (var row in settings.Rows) 2077 { 2078 @Render(row) 2079 } 2080 </tbody> 2081 @if (settings.Footer != null) 2082 { 2083 <tfoot> 2084 @Render(settings.Footer) 2085 </tfoot> 2086 } 2087 </table> 2088 } 2089 @using Dynamicweb.Rapido.Blocks.Components.General 2090 @using Dynamicweb.Rapido.Blocks.Components 2091 2092 @helper RenderTableRow(TableRow settings) 2093 { 2094 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2095 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2096 2097 var enumToClasses = new Dictionary<TableRowDesign, string> 2098 { 2099 { TableRowDesign.NoBorder, "table__row--no-border" }, 2100 { TableRowDesign.Border, "table__row--border" }, 2101 { TableRowDesign.TopBorder, "table__row--top-line" }, 2102 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 2103 { TableRowDesign.Solid, "table__row--solid" } 2104 }; 2105 2106 string tableRowDesignClass = ""; 2107 if (settings.Design != TableRowDesign.None) 2108 { 2109 tableRowDesignClass = enumToClasses[settings.Design]; 2110 } 2111 2112 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2113 2114 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2115 2116 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2117 @foreach (var cell in settings.Cells) 2118 { 2119 if (settings.IsHeaderRow) 2120 { 2121 cell.IsHeader = true; 2122 } 2123 @Render(cell) 2124 } 2125 </tr> 2126 } 2127 @using Dynamicweb.Rapido.Blocks.Components.General 2128 @using Dynamicweb.Rapido.Blocks.Components 2129 @using Dynamicweb.Core 2130 2131 @helper RenderTableCell(TableCell settings) 2132 { 2133 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2134 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2135 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2136 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2137 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2138 2139 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2140 2141 string tagName = settings.IsHeader ? "th" : "td"; 2142 2143 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2144 @settings.Content 2145 @("</" + tagName + ">"); 2146 } 2147 @using System.Linq 2148 @using Dynamicweb.Rapido.Blocks.Components.General 2149 2150 @* Component *@ 2151 2152 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2153 { 2154 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2155 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2156 2157 if (settings.NumberOfPages > 1) 2158 { 2159 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2160 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2161 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2162 2163 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2164 @if (settings.ShowPagingInfo) 2165 { 2166 <div class="pager__info dw-mod"> 2167 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2168 </div> 2169 } 2170 <ul class="pager__list dw-mod"> 2171 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2172 { 2173 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2174 } 2175 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2176 { 2177 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2178 } 2179 @if (settings.GetPages().Any()) 2180 { 2181 foreach (var page in settings.GetPages()) 2182 { 2183 @Render(page) 2184 } 2185 } 2186 else 2187 { 2188 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2189 { 2190 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2191 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2192 } 2193 } 2194 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2195 { 2196 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2197 } 2198 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2199 { 2200 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2201 } 2202 </ul> 2203 </div> 2204 } 2205 } 2206 2207 @helper RenderPaginationItem(PaginationItem settings) 2208 { 2209 if (settings.Icon == null) 2210 { 2211 settings.Icon = new Icon(); 2212 } 2213 2214 settings.Icon.Label = settings.Label; 2215 <li class="pager__btn dw-mod"> 2216 @if (settings.IsActive) 2217 { 2218 <span class="pager__num pager__num--current dw-mod"> 2219 @Render(settings.Icon) 2220 </span> 2221 } 2222 else 2223 { 2224 <a href="@settings.Link" class="pager__num dw-mod"> 2225 @Render(settings.Icon) 2226 </a> 2227 } 2228 </li> 2229 } 2230 2231 2232 @using Dynamicweb.Rapido.Blocks.Components.General 2233 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2234 2235 2236 @using Dynamicweb.Frontend 2237 @using System.Reflection 2238 @using Dynamicweb.Content.Items 2239 @using System.Web.UI.HtmlControls 2240 @using Dynamicweb.Rapido.Blocks.Components 2241 @using Dynamicweb.Rapido.Blocks 2242 @using Dynamicweb.Rapido.Blocks.Components.Articles 2243 2244 @* Components for the articles *@ 2245 @using System.Reflection 2246 @using Dynamicweb.Rapido.Blocks.Components.Articles 2247 2248 2249 @* Component for the articles *@ 2250 2251 @helper RenderArticleBanner(dynamic settings) { 2252 string filterClasses = "image-filter image-filter--darken"; 2253 settings.Layout = ArticleHeaderLayout.Banner; 2254 2255 if (settings.Image != null) 2256 { 2257 if (settings.Image.Path != null) 2258 { 2259 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width"> 2260 <div class="background-image @filterClasses dw-mod"> 2261 <div class="background-image__wrapper @filterClasses dw-mod"> 2262 @{ 2263 settings.Image.CssClass += "background-image__cover dw-mod"; 2264 } 2265 @Render(settings.Image) 2266 </div> 2267 </div> 2268 <div class="center-container dw-mod"> 2269 <div class="grid"> 2270 <div class="grid__col-md-8 grid__col-xs-12 paragraph-container paragraph-container--height-lg"> 2271 <div class="u-left-middle"> 2272 <div> 2273 @if (!String.IsNullOrEmpty(settings.Heading)) 2274 { 2275 <h1 class="article__header article__header--giant dw-mod" style="color: @settings.TextColor">@settings.Heading</h1> 2276 } 2277 @if (!String.IsNullOrEmpty(settings.Subheading)) 2278 { 2279 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div> 2280 } 2281 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2282 { 2283 <small class="article__post-info u-margin-bottom--lg dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small> 2284 } 2285 @if (!String.IsNullOrEmpty(settings.Link)) { 2286 <div class="grid__cell"> 2287 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2288 </div> 2289 } 2290 </div> 2291 </div> 2292 </div> 2293 @if (settings.ExternalParagraphId != 0) 2294 { 2295 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod"> 2296 <div class="u-color-light-gray--bg u-color-dark dw-mod"> 2297 @RenderParagraphContent(settings.ExternalParagraphId) 2298 </div> 2299 </div> 2300 } 2301 2302 </div> 2303 </div> 2304 </section> 2305 if (!String.IsNullOrEmpty(settings.Image.Caption)) { 2306 <div class="image-caption dw-mod">@settings.Image.Caption</div> 2307 } 2308 } 2309 else 2310 { 2311 settings.Layout = ArticleHeaderLayout.Clean; 2312 @RenderArticleCleanHeader(settings); 2313 } 2314 } 2315 else 2316 { 2317 settings.Layout = ArticleHeaderLayout.Clean; 2318 @RenderArticleCleanHeader(settings); 2319 } 2320 } 2321 @using System.Reflection 2322 @using Dynamicweb.Rapido.Blocks.Components 2323 @using Dynamicweb.Rapido.Blocks.Components.General 2324 @using Dynamicweb.Rapido.Blocks.Components.Articles 2325 @using Dynamicweb.Rapido.Blocks 2326 2327 2328 @* Component for the articles *@ 2329 2330 @helper RenderArticleHeader(ArticleHeader settings) { 2331 dynamic[] methodParameters = new dynamic[1]; 2332 methodParameters[0] = settings; 2333 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleHeaderCustom"); 2334 2335 if (customMethod != null) 2336 { 2337 @customMethod.Invoke(this, methodParameters).ToString(); 2338 } else { 2339 switch (settings.Layout) 2340 { 2341 case ArticleHeaderLayout.Clean: 2342 @RenderArticleCleanHeader(settings); 2343 break; 2344 case ArticleHeaderLayout.Split: 2345 @RenderArticleSplitHeader(settings); 2346 break; 2347 case ArticleHeaderLayout.Banner: 2348 @RenderArticleBannerHeader(settings); 2349 break; 2350 case ArticleHeaderLayout.Overlay: 2351 @RenderArticleOverlayHeader(settings); 2352 break; 2353 default: 2354 @RenderArticleCleanHeader(settings); 2355 break; 2356 } 2357 } 2358 } 2359 2360 @helper RenderArticleCleanHeader(ArticleHeader settings) { 2361 dynamic[] methodParameters = new dynamic[1]; 2362 methodParameters[0] = settings; 2363 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleCleanHeaderCustom"); 2364 2365 if (customMethod != null) 2366 { 2367 @customMethod.Invoke(this, methodParameters).ToString(); 2368 } 2369 else 2370 { 2371 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12"; 2372 2373 <div class="grid grid--align-content-start grid--justify-start"> 2374 <div class="grid__col-md-@contentColumns grid__col-sm-12 u-padding--lg dw-mod"> 2375 @if (!String.IsNullOrEmpty(settings.Category) || !String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date) || settings.RatingOutOf != 0) 2376 { 2377 <div class="u-border-bottom u-padding-bottom"> 2378 @if (!String.IsNullOrEmpty(settings.Category)) 2379 { 2380 <div class="u-pull--left"> 2381 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div> 2382 </div> 2383 } 2384 <div class="u-pull--right"> 2385 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2386 { 2387 <small class="article__post-info dw-mod">@settings.Author @settings.Date</small> 2388 } 2389 @if (settings.RatingOutOf != 0) 2390 { 2391 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2392 } 2393 </div> 2394 </div> 2395 } 2396 2397 <div class="grid__cell"> 2398 @if (!String.IsNullOrEmpty(settings.Heading)) 2399 { 2400 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1> 2401 } 2402 @if (settings.Image != null) 2403 { 2404 if (settings.Image.Path != null) 2405 { 2406 <div class="u-padding-bottom--lg"> 2407 @Render(settings.Image) 2408 </div> 2409 } 2410 } 2411 @if (!String.IsNullOrEmpty(settings.Subheading)) 2412 { 2413 <div class="article__leadtext dw-mod">@settings.Subheading</div> 2414 } 2415 @if (!String.IsNullOrEmpty(settings.Link)) 2416 { 2417 <div class="grid__cell"> 2418 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2419 </div> 2420 } 2421 </div> 2422 </div> 2423 @if (settings.ExternalParagraphId != 0) 2424 { 2425 <div class="grid__col-md-4 grid__col-sm-12 u-padding--lg u-color-light-gray--bg dw-mod"> 2426 @RenderParagraphContent(settings.ExternalParagraphId) 2427 </div> 2428 } 2429 </div> 2430 } 2431 } 2432 2433 @helper RenderArticleSplitHeader(ArticleHeader settings) { 2434 dynamic[] methodParameters = new dynamic[1]; 2435 methodParameters[0] = settings; 2436 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleSplitHeaderCustom"); 2437 2438 if (customMethod != null) 2439 { 2440 @customMethod.Invoke(this, methodParameters).ToString(); 2441 } 2442 else 2443 { 2444 string headerColumnWidth = settings.ExternalParagraphId != 0 ? "4" : "6"; 2445 2446 if (settings.Image != null) 2447 { 2448 if (settings.Image.Path != null) 2449 { 2450 <section class="multiple-paragraphs-container paragraph-container--full-width"> 2451 <div class="grid"> 2452 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-xl dw-mod"> 2453 <div class="u-left-middle u-padding--lg"> 2454 <div> 2455 @if (!String.IsNullOrEmpty(settings.Category)) 2456 { 2457 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div> 2458 } 2459 @if (!String.IsNullOrEmpty(settings.Heading)) 2460 { 2461 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1> 2462 } 2463 @if (!String.IsNullOrEmpty(settings.Subheading)) 2464 { 2465 <div class="article__leadtext dw-mod">@settings.Subheading</div> 2466 } 2467 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2468 { 2469 <small class="article__post-info u-pull--left dw-mod">@settings.Author @settings.Date</small> 2470 } 2471 @if (settings.RatingOutOf != 0) 2472 { 2473 <div class="u-pull--right"> 2474 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2475 </div> 2476 } 2477 @if (!String.IsNullOrEmpty(settings.Link)) { 2478 <div class="u-full-width u-pull--left u-margin-top"> 2479 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2480 </div> 2481 } 2482 </div> 2483 </div> 2484 </div> 2485 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod" style="background-image:url(/Admin/Public/GetImage.ashx?width=1800&amp;height=1100&amp;crop=0&amp;Compression=85&amp;DoNotUpscale=true&amp;image=@settings.Image.Path); background-position: center center; background-size: cover;"></div> 2486 @if (settings.ExternalParagraphId != 0) 2487 { 2488 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto u-color-light-gray--bg dw-mod"> 2489 @RenderParagraphContent(settings.ExternalParagraphId) 2490 </div> 2491 } 2492 </div> 2493 </section> 2494 } 2495 } 2496 else 2497 { 2498 @RenderArticleCleanHeader(settings); 2499 } 2500 } 2501 } 2502 2503 @helper RenderArticleOverlayHeader(ArticleHeader settings) { 2504 dynamic[] methodParameters = new dynamic[1]; 2505 methodParameters[0] = settings; 2506 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleOverlayHeaderCustom"); 2507 2508 if (customMethod != null) 2509 { 2510 @customMethod.Invoke(this, methodParameters).ToString(); 2511 } 2512 else 2513 { 2514 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12"; 2515 string contentAlignment = settings.TextLayout == ArticleHeaderTextLayout.Center ? "grid--justify-center" : ""; 2516 2517 if (settings.Image != null) 2518 { 2519 if (settings.Image.Path != null) 2520 { 2521 if (settings.ExternalParagraphId == 0) 2522 { 2523 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width"> 2524 <div class="background-image image-filter image-filter--darken dw-mod"> 2525 <div class="background-image__wrapper image-filter image-filter--darken dw-mod"> 2526 @{ 2527 settings.Image.CssClass += "background-image__cover dw-mod"; 2528 } 2529 @Render(settings.Image) 2530 </div> 2531 </div> 2532 <div class="center-container dw-mod"> 2533 <div class="grid @contentAlignment"> 2534 <div class="grid__col-md-@contentColumns grid__col-xs-12 paragraph-container paragraph-container--height-xl dw-mod"> 2535 @if (!string.IsNullOrEmpty(settings.Heading)) 2536 { 2537 <h1 class="article__header article__header--giant u-padding-top--lg dw-mod" style="color: @settings.TextColor">@settings.Heading</h1> 2538 } 2539 @if (!String.IsNullOrEmpty(settings.Subheading)) 2540 { 2541 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div> 2542 } 2543 <div class="u-margin-top"> 2544 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2545 { 2546 <small class="article__post-info u-pull--left dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small> 2547 } 2548 @if (settings.RatingOutOf != 0) 2549 { 2550 <div class="u-pull--right"> 2551 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf }) 2552 </div> 2553 } 2554 </div> 2555 @if (!String.IsNullOrEmpty(settings.Link)) 2556 { 2557 <div class="grid__cell"> 2558 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2559 </div> 2560 } 2561 </div> 2562 </div> 2563 </div> 2564 </section> 2565 } 2566 else 2567 { 2568 @RenderArticleBanner(settings); 2569 } 2570 } 2571 } 2572 else 2573 { 2574 @RenderArticleCleanHeader(settings); 2575 } 2576 } 2577 } 2578 2579 @helper RenderArticleBannerHeader(dynamic settings) { 2580 dynamic[] methodParameters = new dynamic[1]; 2581 methodParameters[0] = settings; 2582 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleBannerHeaderCustom"); 2583 2584 if (customMethod != null) 2585 { 2586 @customMethod.Invoke(this, methodParameters).ToString(); 2587 } 2588 else 2589 { 2590 @RenderArticleBanner(settings); 2591 } 2592 } 2593 @using System.Reflection 2594 @using System.Text.RegularExpressions; 2595 @using Dynamicweb.Frontend 2596 @using Dynamicweb.Content.Items 2597 @using Dynamicweb.Rapido.Blocks.Components 2598 @using Dynamicweb.Rapido.Blocks.Components.Articles 2599 @using Dynamicweb.Rapido.Blocks 2600 2601 @* Component for the articles *@ 2602 2603 @helper RenderArticleBodyRow(ArticleBodyRow settings) 2604 { 2605 string position = settings.TopLayout == "overlay" ? "article__overlay-offset" : ""; 2606 string contentAlignment = settings.TextLayout == "center" ? "grid--justify-center" : ""; 2607 2608 <div class="grid grid--align-content-start @contentAlignment @position dw-mod"> 2609 @RenderBlockList(settings.SubBlocks) 2610 </div> 2611 } 2612 @using System.Reflection 2613 @using Dynamicweb.Rapido.Blocks.Components 2614 @using Dynamicweb.Rapido.Blocks.Components.General 2615 @using Dynamicweb.Rapido.Blocks.Components.Articles 2616 @using Dynamicweb.Rapido.Blocks 2617 2618 @* Component for the articles *@ 2619 2620 @helper RenderArticleImage(ArticleImage settings) 2621 { 2622 if (settings.Image != null) 2623 { 2624 if (settings.Image.Path != null) 2625 { 2626 <div class="u-margin-bottom--lg"> 2627 @Render(settings.Image) 2628 </div> 2629 } 2630 } 2631 } 2632 @using System.Reflection 2633 @using Dynamicweb.Rapido.Blocks.Components 2634 @using Dynamicweb.Rapido.Blocks.Components.Articles 2635 2636 2637 @* Component for the articles *@ 2638 2639 @helper RenderArticleSubHeader(ArticleSubHeader settings) 2640 { 2641 if (!String.IsNullOrEmpty(settings.Title)) 2642 { 2643 <h2 class="article__header">@settings.Title</h2> 2644 } 2645 } 2646 @using System.Reflection 2647 @using Dynamicweb.Rapido.Blocks.Components 2648 @using Dynamicweb.Rapido.Blocks.Components.Articles 2649 @using Dynamicweb.Rapido.Blocks 2650 2651 2652 @* Component for the articles *@ 2653 2654 @helper RenderArticleText(ArticleText settings) 2655 { 2656 if (!String.IsNullOrEmpty(settings.Text)) 2657 { 2658 string greatTextClass = settings.EnableLargeText == true ? "article__paragraph--great-text" : ""; 2659 2660 <div class="article__paragraph @greatTextClass dw-mod"> 2661 @settings.Text 2662 </div> 2663 } 2664 } 2665 @using System.Reflection 2666 @using Dynamicweb.Rapido.Blocks.Components 2667 @using Dynamicweb.Rapido.Blocks.Components.Articles 2668 @using Dynamicweb.Rapido.Blocks 2669 2670 2671 @* Component for the articles *@ 2672 2673 @helper RenderArticleQuote(ArticleQuote settings) 2674 { 2675 string text = Regex.Replace(settings.Text, "<.*?>", String.Empty); 2676 2677 <div class="grid u-padding-bottom--lg"> 2678 @if (settings.Image != null) 2679 { 2680 if (settings.Image.Path != null) { 2681 <div class="grid__col-3"> 2682 <div class="grid__cell-img"> 2683 @{ 2684 settings.Image.Title = !String.IsNullOrEmpty(settings.Image.Title) ? settings.Image.Title : settings.Author; 2685 settings.Image.CssClass += " article__image article__image--ball"; 2686 settings.Image.ImageDefault.Width = 200; 2687 settings.Image.ImageDefault.Height = 200; 2688 } 2689 @Render(settings.Image) 2690 </div> 2691 </div> 2692 } 2693 } 2694 <div class="grid__col-auto"> 2695 @if (!String.IsNullOrEmpty(settings.Text)) 2696 { 2697 <div class="article__quote dw-mod"> 2698 <i class="fas fa-quote-right u-margin-bottom--lg"></i> 2699 @settings.Text 2700 <i class="fas fa-quote-right"></i> 2701 </div> 2702 } 2703 @if (!String.IsNullOrEmpty(settings.Author)) 2704 { 2705 <div class="article__quote-author dw-mod"> 2706 - @settings.Author 2707 </div> 2708 } 2709 </div> 2710 </div> 2711 } 2712 @using System.Reflection 2713 @using Dynamicweb.Rapido.Blocks.Components 2714 @using Dynamicweb.Rapido.Blocks.Components.Articles 2715 @using Dynamicweb.Rapido.Blocks 2716 2717 @* Component for the articles *@ 2718 2719 @helper RenderArticleInfoTable(ArticleInfoTable settings) 2720 { 2721 <table class="table table--clean"> 2722 @foreach (var row in settings.Rows) 2723 { 2724 string iconColor = row.IconColor != null ? row.IconColor : "u-brand-color-two"; 2725 2726 <tr> 2727 @if (!String.IsNullOrEmpty(row.Icon)) 2728 { 2729 <td class="u-w32px"><i class="@row.Icon fa-2x @row.IconColor"></i></td> 2730 } 2731 <td class="u-no-margin-on-p-elements"> 2732 <div class="u-bold">@row.Title</div> 2733 @if (!String.IsNullOrEmpty(row.SubTitle)) 2734 { 2735 if (row.Link == null) 2736 { 2737 <div>@row.SubTitle</div> 2738 } 2739 else 2740 { 2741 <a href="@row.Link" class="u-color-inherit">@row.SubTitle</a> 2742 } 2743 } 2744 </td> 2745 </tr> 2746 } 2747 </table> 2748 } 2749 @using System.Reflection 2750 @using Dynamicweb.Rapido.Blocks.Components 2751 @using Dynamicweb.Rapido.Blocks.Components.General 2752 @using Dynamicweb.Rapido.Blocks.Components.Articles 2753 @using Dynamicweb.Rapido.Blocks 2754 2755 @* Component for the articles *@ 2756 2757 @helper RenderArticleGalleryModal(ArticleGalleryModal settings) 2758 { 2759 Modal galleryModal = new Modal 2760 { 2761 Id = "ParagraphGallery", 2762 Width = ModalWidth.Full, 2763 BodyTemplate = RenderArticleGalleryModalContent() 2764 }; 2765 2766 @Render(galleryModal) 2767 } 2768 2769 @helper RenderArticleGalleryModalContent() { 2770 <div class="modal__image-min-size-wrapper"> 2771 @Render(new Image { 2772 Id = "ParagraphGallery", 2773 Path = "#", 2774 CssClass = "modal--full__img", 2775 DisableLazyLoad = true, 2776 DisableImageEngine = true 2777 }) 2778 </div> 2779 2780 <div class="modal__images-counter" id="ParagraphGallery_counter"></div> 2781 2782 @Render(new Button { 2783 Id = "ParagraphGallery_prev", 2784 ButtonType = ButtonType.Button, 2785 ButtonLayout = ButtonLayout.None, 2786 CssClass = "modal__prev-btn", 2787 Icon = new Icon { Prefix = "far", Name = "fa-angle-left", LabelPosition = IconLabelPosition.After }, 2788 OnClick = "Gallery.prevImage('ParagraphGallery')" 2789 }) 2790 2791 @Render(new Button { 2792 Id = "ParagraphGallery_next", 2793 ButtonType = ButtonType.Button, 2794 ButtonLayout = ButtonLayout.None, 2795 CssClass = "modal__next-btn", 2796 Icon = new Icon { Prefix = "far", Name = "fa-angle-right", LabelPosition = IconLabelPosition.After }, 2797 OnClick = "Gallery.nextImage('ParagraphGallery')" 2798 }) 2799 } 2800 @using System.Reflection 2801 @using Dynamicweb.Rapido.Blocks.Components 2802 @using Dynamicweb.Rapido.Blocks.Components.Articles 2803 @using Dynamicweb.Rapido.Blocks 2804 2805 2806 @* Component for the articles *@ 2807 2808 @helper RenderArticleRelated(ArticleRelated settings) 2809 { 2810 string cardClass = Pageview.Device.ToString() != "Tablet" ? "card u-color-light--bg u-full-height" : ""; 2811 string cardFooterClass = Pageview.Device.ToString() != "Tablet" ? "card-footer u-color-light--bg" : ""; 2812 2813 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width"> 2814 <div class="center-container dw-mod"> 2815 <div class="grid u-padding"> 2816 <div class="grid__col-md-12 grid__col-xs-12"> 2817 <h2 class="article__header u-no-margin u-margin-top">@settings.Title</h2> 2818 </div> 2819 </div> 2820 2821 <div class="js-handlebars-root u-padding" id="@settings.Title.Replace(" ", String.Empty)" data-template="RelatedSimpleTemplate" data-json-feed="/Default.aspx?ID=@settings.FeedPageId&@settings.Query&ExcludeItemID=@settings.CurrentPageId&PageSize=@settings.PageSize"></div> 2822 2823 <script id="RelatedSimpleTemplate" type="text/x-template"> 2824 {{#.}} 2825 <div class="grid u-padding-bottom--lg"> 2826 {{#Cases}} 2827 <div class="grid__col-lg-3 grid__col-sm-6 image-hover--zoom dw-mod"> 2828 <a href="{{link}}" class="u-full-height u-color-light--bg u-flex u-flex--column"> 2829 {{#if image}} 2830 <div class="u-color-light--bg u-no-padding dw-mod"> 2831 <div class="flex-img image-hover__wrapper"> 2832 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=680&height=314&amp;crop=1&amp;DoNotUpscale=True&amp;Compression=75&amp;image={{image}}" alt="{{title}}" /> 2833 </div> 2834 </div> 2835 {{/if}} 2836 2837 <div class="card u-color-light--bg u-full-height dw-mod"> 2838 <h3 class="article-list__item-header u-truncate-text dw-mod">{{title}}</h3> 2839 <p class="article__short-summary dw-mod">{{summary}}</p> 2840 </div> 2841 </a> 2842 </div> 2843 {{/Cases}} 2844 </div> 2845 {{/.}} 2846 </script> 2847 </div> 2848 </section> 2849 } 2850 @using System.Reflection 2851 @using Dynamicweb.Rapido.Blocks.Components 2852 @using Dynamicweb.Rapido.Blocks.Components.Articles 2853 @using Dynamicweb.Rapido.Blocks 2854 2855 2856 @* Component for the articles *@ 2857 2858 @helper RenderArticleMenu(ArticleMenu settings) 2859 { 2860 if (!String.IsNullOrEmpty(settings.Title)) { 2861 <div class="u-margin u-border-bottom"> 2862 <h3 class="u-no-margin">@settings.Title</h3> 2863 </div> 2864 } 2865 2866 <ul class="menu-left u-margin-bottom dw-mod"> 2867 @foreach (var item in settings.Items) 2868 { 2869 @Render(item) 2870 } 2871 </ul> 2872 } 2873 2874 @helper RenderArticleMenuItem(ArticleMenuItem settings) 2875 { 2876 string link = !String.IsNullOrEmpty(settings.Link) ? settings.Link : "#"; 2877 2878 if (!String.IsNullOrEmpty(settings.Title)) { 2879 <li class="menu-left__item dw-mod"> 2880 <a href="@link" onclick="@settings.OnClick" class="menu-left__link dw-mod">@settings.Title</a> 2881 </li> 2882 } 2883 } 2884 @using System.Reflection 2885 @using Dynamicweb.Rapido.Blocks.Components 2886 @using Dynamicweb.Rapido.Blocks.Components.Articles 2887 @using Dynamicweb.Rapido.Blocks 2888 2889 @* Component for the articles *@ 2890 2891 @helper RenderArticleList(ArticleList settings) 2892 { 2893 if (Pageview != null) 2894 { 2895 bool isParagraph = Pageview.CurrentParagraph != null ? true : false; 2896 string[] sortArticlesListBy = new string[2]; 2897 2898 if (isParagraph) { 2899 sortArticlesListBy = Pageview.CurrentParagraph.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString()) ? Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" }; 2900 } 2901 else { 2902 sortArticlesListBy = Pageview.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.Item["SortArticlesListBy"].ToString()) ? Pageview.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" }; 2903 } 2904 2905 string sourcePage = settings.SourcePage != null ? settings.SourcePage : Pageview.ID.ToString(); 2906 2907 if (!settings.DisablePagination) { 2908 @RenderItemList(new 2909 { 2910 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle", 2911 ListSourceType = settings.SourceType, 2912 ListSourcePage = sourcePage, 2913 ItemFieldsList = "*", 2914 Filter = settings.Filter, 2915 ListOrderBy = sortArticlesListBy[0], 2916 ListOrderByDirection = sortArticlesListBy[1], 2917 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date", 2918 ListSecondOrderByDirection = "ASC", 2919 IncludeAllChildItems = true, 2920 ListTemplate = settings.Template, 2921 ListPageSize = settings.PageSize.ToString() 2922 }); 2923 } else { 2924 @RenderItemList(new 2925 { 2926 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle", 2927 ListSourceType = settings.SourceType, 2928 ListSourcePage = sourcePage, 2929 ItemFieldsList = "*", 2930 Filter = settings.Filter, 2931 ListOrderBy = sortArticlesListBy[0], 2932 ListOrderByDirection = sortArticlesListBy[1], 2933 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date", 2934 ListSecondOrderByDirection = "ASC", 2935 IncludeAllChildItems = true, 2936 ListTemplate = settings.Template, 2937 ListPageSize = settings.PageSize.ToString(), 2938 ListViewMode = "Partial", 2939 ListShowTo = settings.PageSize + 1 2940 }); 2941 } 2942 } 2943 } 2944 @using System.Reflection 2945 @using Dynamicweb.Rapido.Blocks.Components.Articles 2946 2947 2948 @* Component for the articles *@ 2949 2950 @helper RenderArticleSummary(ArticleSummary settings) 2951 { 2952 if (!String.IsNullOrEmpty(settings.Text)) 2953 { 2954 <div class="article__summary dw-mod">@settings.Text</div> 2955 } 2956 } 2957 @using System.Reflection 2958 @using Dynamicweb.Rapido.Blocks.Components 2959 @using Dynamicweb.Rapido.Blocks.Components.Articles 2960 @using Dynamicweb.Rapido.Blocks 2961 2962 @* Component for the articles *@ 2963 2964 @helper RenderArticleListCategoryFilter(ArticleListCategoryFilter settings) 2965 { 2966 string pageId = Pageview.ID.ToString(); 2967 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("sourcePage")) ? HttpContext.Current.Request.QueryString.Get("sourcePage") : Translate("All"); 2968 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString()); 2969 2970 foreach (var option in settings.Categories) 2971 { 2972 selectedFilter = selectedFilter == option.Value ? option.Key : selectedFilter; 2973 } 2974 2975 if (selectedFilter == pageId) 2976 { 2977 selectedFilter = Translate("All"); 2978 } 2979 2980 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 2981 { 2982 <div class="u-pull--right u-margin-left"> 2983 <div class="collection u-no-margin"> 2984 <h5>@Translate("Category")</h5> 2985 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" /> 2986 <div class="dropdown u-w180px dw-mod"> 2987 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label> 2988 <div class="dropdown__content dw-mod"> 2989 @foreach (var option in settings.Categories) 2990 { 2991 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div> 2992 } 2993 </div> 2994 <label class="dropdown-trigger-off" for="CategorySelector"></label> 2995 </div> 2996 </div> 2997 </div> 2998 } 2999 else 3000 { 3001 <div class="u-full-width u-margin-bottom"> 3002 <h5 class="u-no-margin">@Translate("Category")</h5> 3003 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" /> 3004 <div class="dropdown u-full-width dw-mod"> 3005 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label> 3006 <div class="dropdown__content dw-mod"> 3007 @foreach (var option in settings.Categories) 3008 { 3009 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div> 3010 } 3011 </div> 3012 <label class="dropdown-trigger-off" for="CategorySelector"></label> 3013 </div> 3014 </div> 3015 } 3016 } 3017 @using System.Reflection 3018 @using Dynamicweb.Rapido.Blocks.Components 3019 @using Dynamicweb.Rapido.Blocks.Components.Articles 3020 @using Dynamicweb.Rapido.Blocks 3021 @using System.Collections.Generic 3022 3023 @* Component for the articles *@ 3024 3025 @helper RenderArticleListFilter(ArticleListFilter settings) 3026 { 3027 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get(settings.SystemName)) ? HttpContext.Current.Request.QueryString.Get(settings.SystemName) : Translate("All"); 3028 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString()); 3029 3030 if (settings.Options != null) 3031 { 3032 if (settings.Options is IEnumerable<dynamic>) 3033 { 3034 var options = (IEnumerable<dynamic>) settings.Options; 3035 settings.Options = options.OrderBy(item => item.Name); 3036 } 3037 3038 foreach (var option in settings.Options) 3039 { 3040 selectedFilter = selectedFilter == option.Value ? option.Name : selectedFilter; 3041 } 3042 3043 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 3044 { 3045 <div class="u-pull--right u-margin-left"> 3046 <div class="collection u-no-margin"> 3047 <h5>@settings.Label</h5> 3048 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" /> 3049 <div class="dropdown u-w180px dw-mod"> 3050 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label> 3051 <div class="dropdown__content dw-mod"> 3052 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div> 3053 @foreach (var option in settings.Options) 3054 { 3055 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div> 3056 } 3057 </div> 3058 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label> 3059 </div> 3060 </div> 3061 </div> 3062 } 3063 else 3064 { 3065 <div class="u-full-width u-margin-bottom"> 3066 <h5 class="u-no-margin">@settings.Label</h5> 3067 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" /> 3068 <div class="dropdown u-full-width w-mod"> 3069 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label> 3070 <div class="dropdown__content dw-mod"> 3071 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div> 3072 @foreach (var option in settings.Options) 3073 { 3074 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div> 3075 } 3076 </div> 3077 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label> 3078 </div> 3079 </div> 3080 } 3081 } 3082 } 3083 @using System.Reflection 3084 @using Dynamicweb.Rapido.Blocks.Components 3085 @using Dynamicweb.Rapido.Blocks.Components.Articles 3086 @using Dynamicweb.Rapido.Blocks 3087 3088 @* Component for the articles *@ 3089 3090 @helper RenderArticleListSearch(ArticleListSearch settings) 3091 { 3092 string searchParameter = !string.IsNullOrEmpty(settings.SearchParameter) ? settings.SearchParameter : "Title"; 3093 string searchWord = HttpContext.Current.Request.QueryString.Get(searchParameter); 3094 string searchString = !string.IsNullOrEmpty(searchWord) ? searchWord.Trim('*') : ""; 3095 string className = "u-w340px u-pull--right u-margin-left"; 3096 3097 if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet") 3098 { 3099 className = "u-full-width"; 3100 } 3101 3102 <div class="typeahead u-color-inherit u-margin-bottom dw-mod @className"> 3103 <input type="text" class="typeahead-search-field u-no-margin dw-mod" placeholder="@Translate("Search in list")" value="@searchString" id="ArticleListSearchInput" onchange="QueryArray.setParameterInCurrentURL('@searchParameter', '*' + document.getElementById('ArticleListSearchInput').value + '*')"> 3104 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod"><i class="fas fa-search"></i></button> 3105 </div> 3106 } 3107 @using System.Reflection 3108 @using Dynamicweb.Rapido.Blocks.Components 3109 @using Dynamicweb.Rapido.Blocks.Components.Articles 3110 @using Dynamicweb.Rapido.Blocks 3111 3112 @* Component for the articles *@ 3113 3114 @helper RenderArticleListNoResultsInfo(ArticleListNoResultsInfo settings) 3115 { 3116 <div class="u-margin-top--lg u-bold u-ta-center u-bold">@Translate(settings.Message)</div> 3117 } 3118 @using System.Reflection 3119 @using Dynamicweb.Rapido.Blocks.Components 3120 @using Dynamicweb.Rapido.Blocks.Components.General 3121 @using Dynamicweb.Rapido.Blocks.Components.Articles 3122 @using Dynamicweb.Rapido.Blocks 3123 @using System.Text.RegularExpressions 3124 3125 @* Component for the articles *@ 3126 3127 @helper RenderArticleListItem(ArticleListItem settings) 3128 { 3129 switch (settings.Type) { 3130 case ArticleListItemType.Card: 3131 @RenderArticleListItemCard(settings); 3132 break; 3133 case ArticleListItemType.List: 3134 @RenderArticleListItemList(settings); 3135 break; 3136 case ArticleListItemType.Simple: 3137 @RenderArticleListItemSimple(settings); 3138 break; 3139 default: 3140 @RenderArticleListItemCard(settings); 3141 break; 3142 } 3143 } 3144 3145 @helper RenderArticleListItemCard(ArticleListItem settings) { 3146 <a href="@settings.Link" class="u-full-height u-color-light--bg u-flex u-flex--column"> 3147 <div class="u-color-light--bg u-no-padding dw-mod"> 3148 @if (settings.Logo != null) 3149 { 3150 string backgroundImage = settings.Image != null ? "background-image:url(/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=True&amp;image=" + settings.Image.Path + "); background-size: cover;" : ""; 3151 settings.Logo.ImageDefault.Crop = 5; 3152 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width; 3153 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height; 3154 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage"> 3155 @if (settings.Stickers != null) 3156 { 3157 if (settings.Stickers.Position != StickersListPosition.Custom && settings.Stickers.Position != StickersListPosition.None) 3158 { 3159 @Render(settings.Stickers); 3160 } 3161 } 3162 @RenderImage(settings.Logo) 3163 </div> 3164 } else if (settings.Image != null) 3165 { 3166 <div class="flex-img image-hover__wrapper u-position-relative dw-mod"> 3167 @if (settings.Stickers != null) 3168 { 3169 if (settings.Stickers.Position != StickersListPosition.Custom && settings.Stickers.Position != StickersListPosition.None) 3170 { 3171 @Render(settings.Stickers); 3172 } 3173 } 3174 @Render(settings.Image) 3175 </div> 3176 } 3177 </div> 3178 3179 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary)) 3180 { 3181 <div class="card u-color-light--bg u-full-height dw-mod"> 3182 @if (settings.Stickers != null) 3183 { 3184 if (settings.Stickers.Position == StickersListPosition.Custom) 3185 { 3186 @Render(settings.Stickers); 3187 } 3188 } 3189 @if (!String.IsNullOrEmpty(settings.Title)) 3190 { 3191 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3> 3192 } 3193 @if (!String.IsNullOrEmpty(settings.SubTitle)) 3194 { 3195 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 3196 } 3197 @if (!String.IsNullOrEmpty(settings.Summary)) 3198 { 3199 <p class="article__short-summary dw-mod">@settings.Summary</p> 3200 } 3201 </div> 3202 } 3203 </a> 3204 } 3205 3206 @helper RenderArticleListItemList(ArticleListItem settings) { 3207 <a href="@settings.Link"> 3208 <div class="grid u-color-light--bg u-no-padding dw-mod"> 3209 <div class="grid__col-md-3"> 3210 <div class="u-color-light--bg u-no-padding dw-mod"> 3211 @if (settings.Logo != null) 3212 { 3213 string backgroundImage = settings.Image != null ? "background-image:url(/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=True&amp;image=" + settings.Image.Path + "); background-size: cover;" : ""; 3214 settings.Logo.ImageDefault.Crop = 5; 3215 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width; 3216 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height; 3217 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage"> 3218 @if (settings.Stickers != null) 3219 { 3220 if (settings.Stickers.Position != StickersListPosition.Custom) 3221 { 3222 @Render(settings.Stickers); 3223 } 3224 } 3225 @RenderImage(settings.Logo) 3226 </div> 3227 } else if (settings.Image != null) 3228 { 3229 <div class="flex-img image-hover__wrapper dw-mod"> 3230 @if (settings.Stickers != null) 3231 { 3232 if (settings.Stickers.Position != StickersListPosition.Custom) 3233 { 3234 @Render(settings.Stickers); 3235 } 3236 } 3237 @Render(settings.Image) 3238 </div> 3239 } 3240 </div> 3241 </div> 3242 3243 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary)) 3244 { 3245 <div class="grid__col-md-9"> 3246 @if (!String.IsNullOrEmpty(settings.Title)) 3247 { 3248 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3> 3249 } 3250 @if (settings.Stickers != null) 3251 { 3252 if (settings.Stickers.Position == StickersListPosition.Custom) 3253 { 3254 @Render(settings.Stickers); 3255 } 3256 } 3257 @if (!String.IsNullOrEmpty(settings.SubTitle)) 3258 { 3259 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 3260 } 3261 @if (!String.IsNullOrEmpty(settings.Summary)) 3262 { 3263 <p class="article__short-summary dw-mod">@settings.Summary</p> 3264 } 3265 </div> 3266 } 3267 </div> 3268 </a> 3269 } 3270 3271 @helper RenderArticleListItemSimple(ArticleListItem settings) { 3272 <a href="@settings.Link" class="u-color-inherit"> 3273 <div class="grid u-color-light--bg u-no-padding dw-mod"> 3274 <div class="grid__col-md-12"> 3275 @if (!String.IsNullOrEmpty(settings.Title)) 3276 { 3277 <div class="article-list-item__header u-truncate-text u-no-margin dw-mod">@settings.Title</div> 3278 } 3279 @if (!String.IsNullOrEmpty(settings.SubTitle)) 3280 { 3281 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div> 3282 } 3283 </div> 3284 </div> 3285 </a> 3286 } 3287 @using System.Reflection 3288 @using Dynamicweb.Rapido.Blocks.Components.Articles 3289 3290 3291 @* Component for the articles *@ 3292 3293 @helper RenderArticleAuthorAndDate(ArticleAuthorAndDate settings) 3294 { 3295 <small class="article__subscription"> 3296 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date))) 3297 { 3298 <text>@Translate("Written")</text> 3299 } 3300 @if (!string.IsNullOrWhiteSpace(settings.Author)) 3301 { 3302 <text>@Translate("by") @settings.Author</text> 3303 } 3304 @if (!string.IsNullOrWhiteSpace(settings.Date)) 3305 { 3306 <text>@Translate("on") @settings.Date</text> 3307 } 3308 </small> 3309 } 3310 @using System.Reflection 3311 @using Dynamicweb.Rapido.Blocks.Components.Articles 3312 @using Dynamicweb.Rapido.Blocks.Components.General 3313 3314 3315 @* Component for the articles *@ 3316 3317 @helper RenderArticleLink(ArticleLink settings) 3318 { 3319 if (!string.IsNullOrEmpty(settings.Title)) 3320 { 3321 Button link = new Button { 3322 ConfirmText = settings.ConfirmText, 3323 ConfirmTitle = settings.ConfirmTitle, 3324 ButtonType = settings.ButtonType, 3325 Id = settings.Id, 3326 Title = settings.Title, 3327 AltText = settings.AltText, 3328 OnClick = settings.OnClick, 3329 CssClass = settings.CssClass, 3330 Disabled = settings.Disabled, 3331 Icon = settings.Icon, 3332 Name = settings.Name, 3333 Href = settings.Href, 3334 ButtonLayout = settings.ButtonLayout, 3335 ExtraAttributes = settings.ExtraAttributes 3336 }; 3337 <div class="grid__cell"> 3338 @Render(link) 3339 </div> 3340 } 3341 } 3342 @using System.Reflection 3343 @using Dynamicweb.Rapido.Blocks 3344 @using Dynamicweb.Rapido.Blocks.Components.Articles 3345 @using Dynamicweb.Rapido.Blocks.Components.General 3346 3347 3348 @* Component for the articles *@ 3349 3350 @helper RenderArticleCarousel(ArticleCarousel settings) 3351 { 3352 <div class="grid"> 3353 <div class="grid__col-12 u-no-padding u-margin-bottom"> 3354 <div class="carousel" id="carousel_@settings.Id"> 3355 <div class="carousel__container js-carousel-slides dw-mod"> 3356 @RenderBlockList(settings.SubBlocks) 3357 </div> 3358 </div> 3359 </div> 3360 </div> 3361 3362 <script> 3363 document.addEventListener("DOMContentLoaded", function () { 3364 new CarouselModule("#carousel_@settings.Id", { 3365 slideTime: 0, 3366 dots: true 3367 }); 3368 }); 3369 </script> 3370 } 3371 3372 @helper RenderArticleCarouselSlide(ArticleCarouselSlide settings) 3373 { 3374 string imageEngine = "/Admin/Public/GetImage.ashx?"; 3375 3376 string defaultImage = settings.ImageSettings != null ? imageEngine : settings.Image; 3377 if (settings.ImageSettings != null) 3378 { 3379 defaultImage += settings.ImageSettings.Width != 0 ? "Width=" + settings.ImageSettings.Width + "&" : ""; 3380 defaultImage += settings.ImageSettings.Height != 0 ? "Height=" + settings.ImageSettings.Height + "&" : ""; 3381 defaultImage += "Crop=" + settings.ImageSettings.Crop + "&"; 3382 defaultImage += "Compression=" + settings.ImageSettings.Compression + "&"; 3383 defaultImage += "DoNotUpscale=" + settings.ImageSettings.DoNotUpscale.ToString() + "&"; 3384 defaultImage += "FillCanvas=" + settings.ImageSettings.FillCanvas.ToString() + "&"; 3385 } 3386 defaultImage += "&Image=" + settings.Image; 3387 3388 <div class="carousel__slide u-min-h300px u-flex dw-mod" style="background-size:cover; background-image:url('@defaultImage')"> 3389 <a class="article-carousel-item__wrap" href="@settings.Link" title="@settings.Title"> 3390 <h2 class="article-list__item-header u-truncate-text u-color-light dw-mod">@settings.Title</h2> 3391 <div class="article-list__item-info"> 3392 @if (settings.Stickers != null) 3393 { 3394 settings.Stickers.Position = StickersListPosition.Custom; 3395 @Render(settings.Stickers); 3396 } 3397 3398 <small class="u-margin-top--lg u-color-light"> 3399 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date))) 3400 { 3401 <text>@Translate("Written")</text> 3402 } 3403 @if (!string.IsNullOrWhiteSpace(settings.Author)) 3404 { 3405 <text>@Translate("by") @settings.Author</text> 3406 } 3407 @if (!string.IsNullOrWhiteSpace(settings.Date)) 3408 { 3409 <text>@Translate("on") @settings.Date</text> 3410 } 3411 </small> 3412 </div> 3413 3414 <h3 class="article__short-summary u-color-light">@settings.Summary</h3> 3415 </a> 3416 @if (settings.UseFilters == true) 3417 { 3418 <div class="background-image image-filter image-filter--darken dw-mod"></div> 3419 } 3420 </div> 3421 } 3422 @using System.Text.RegularExpressions 3423 @using Dynamicweb.Rapido.Blocks.Components 3424 @using Dynamicweb.Rapido.Blocks.Components.General 3425 @using Dynamicweb.Rapido.Blocks.Components.Articles 3426 @using Dynamicweb.Rapido.Blocks 3427 3428 @* Component for the articles *@ 3429 3430 @helper RenderArticleVideo(ArticleVideo settings) 3431 { 3432 if (settings.Url != null) 3433 { 3434 //getting video ID from youtube URL 3435 string videoCode = settings.Url; 3436 Regex regex = new Regex(@".be\/(.[^?]*)"); 3437 Match match = regex.Match(videoCode); 3438 string videoId = ""; 3439 if (match.Success) 3440 { 3441 videoId = match.Groups[1].Value; 3442 } 3443 else 3444 { 3445 regex = new Regex(@"v=([^&]+)"); 3446 match = regex.Match(videoCode); 3447 if (match.Success) 3448 { 3449 videoId = match.Groups[1].Value; 3450 } 3451 } 3452 3453 int autoPlay = settings.AutoPlay == "true" ? 1 : 0; 3454 3455 <div class="video-wrapper"> 3456 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Guid.NewGuid().ToString("N"))" data-auto-play="@autoPlay" data-enable-controls="1"></div> 3457 </div> 3458 } 3459 } 3460 3461 3462 3463 @* Simple helpers *@ 3464 3465 @*Requires the Gallery ItemType that comes with Rapido*@ 3466 @helper RenderArticleItemGallery(IList<ItemViewModel> gallery) { 3467 if (gallery != null && gallery.Count > 0) 3468 { 3469 int count = 1; 3470 3471 foreach (var item in gallery) 3472 { 3473 if (item.GetFile("ImagePath") != null) 3474 { 3475 string image = item.GetFile("ImagePath").PathUrlEncoded; 3476 string imagePrefix = "/Admin/Public/GetImage.ashx?width=1200&amp;height=820&amp;crop=5&amp;Compression=75&amp;DoNotUpscale=1&amp;image="; 3477 int imagesCount = gallery.Count; 3478 3479 if (count == 1) 3480 { 3481 <label class="gallery" for="ParagraphGalleryModalTrigger" onclick="Gallery.openImage(this.querySelector('.js-gallery'))"> 3482 <span class="gallery__main-image"> 3483 <img src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=992&amp;height=760&amp;crop=0&amp;Compression=75&amp;DoNotUpscale=1&amp;image=@image" class="b-lazy flex-img js-gallery" alt="" data-for="ParagraphGallery" data-image="@imagePrefix@image" /> 3484 </span> 3485 <span class="gallery__image-counter"> 3486 <i class="fas fa-camera fa-2x"></i> <span class="gallery__image-counter__number">@imagesCount</span> 3487 <span class="gallery__image-counter__text">@Translate("See all") <i class="fas fa-angle-right"></i></span> 3488 </span> 3489 </label> 3490 } 3491 else 3492 { 3493 <div class="u-hidden js-gallery" data-for="ParagraphGallery" data-image="@imagePrefix@image"></div> 3494 } 3495 3496 count++; 3497 } 3498 } 3499 3500 @Render(new ArticleGalleryModal()) 3501 } 3502 } 3503 3504 @helper RenderMobileFilters(List<Block> subBlocks) 3505 { 3506 if (subBlocks.Count > 0) 3507 { 3508 <div class="grid__col-12"> 3509 <input type="checkbox" id="CheckFilters" class="js-remember-state u-hidden" data-expand="CheckFilters" /> 3510 <div class="grid u-margin-bottom dw-mod" data-trigger="CheckFilters"> 3511 @RenderBlockList(subBlocks) 3512 </div> 3513 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod js-expand-hide" data-trigger="CheckFilters">@Translate("Select filters")</label> 3514 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod expandable--collapsed" data-trigger="CheckFilters">@Translate("Close filters")</label> 3515 </div> 3516 } 3517 } 3518 3519 3520 @* Include the Blocks for the page *@ 3521 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3522 3523 @using System 3524 @using System.Web 3525 @using System.Collections.Generic 3526 @using Dynamicweb.Rapido.Blocks.Extensibility 3527 @using Dynamicweb.Rapido.Blocks 3528 3529 @functions { 3530 string GoogleTagManagerID = ""; 3531 string GoogleAnalyticsID = ""; 3532 } 3533 3534 @{ 3535 GoogleTagManagerID = Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID"); 3536 GoogleAnalyticsID = Model.Area.Item.GetItem("Settings").GetString("GoogleAnalyticsTrackingID"); 3537 3538 BlocksPage topSnippetsBlocksPage = BlocksPage.GetBlockPage("Master"); 3539 3540 if (!string.IsNullOrWhiteSpace(GoogleAnalyticsID)) 3541 { 3542 Block tagManager = new Block() 3543 { 3544 Id = "GoogleAnalytics", 3545 SortId = 0, 3546 Template = RenderGoogleAnalyticsSnippet() 3547 }; 3548 topSnippetsBlocksPage.Add("Head", tagManager); 3549 } 3550 3551 if (!string.IsNullOrWhiteSpace(GoogleTagManagerID)) 3552 { 3553 Block tagManager = new Block() 3554 { 3555 Id = "TagManager", 3556 SortId = 1, 3557 Template = RenderGoogleTagManager() 3558 }; 3559 topSnippetsBlocksPage.Add("Head", tagManager); 3560 3561 Block tagManagerBodySnippet = new Block() 3562 { 3563 Id = "TagManagerBodySnippet", 3564 SortId = 1, 3565 Template = RenderGoogleTagManagerBodySnippet() 3566 }; 3567 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, tagManagerBodySnippet); 3568 } 3569 3570 Block facebookPixel = new Block() 3571 { 3572 Id = "FacebookPixel", 3573 SortId = 2, 3574 Template = RenderFacebookPixel() 3575 }; 3576 3577 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, facebookPixel); 3578 } 3579 3580 @helper RenderGoogleAnalyticsSnippet() 3581 { 3582 <!-- Global site tag (gtag.js) - Google Analytics --> 3583 <script async src="https://www.googletagmanager.com/gtag/js?id=@GoogleAnalyticsID"></script> 3584 <script> 3585 window.dataLayer = window.dataLayer || []; 3586 function gtag(){dataLayer.push(arguments);} 3587 gtag('js', new Date()); 3588 3589 gtag('config', '@GoogleAnalyticsID'); 3590 </script> 3591 3592 } 3593 3594 @helper RenderGoogleTagManager() 3595 { 3596 <script> 3597 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 3598 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 3599 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 3600 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 3601 })(window,document,'script','dataLayer','@GoogleTagManagerID'); 3602 </script> 3603 } 3604 3605 @helper RenderGoogleTagManagerBodySnippet() 3606 { 3607 <!-- Google Tag Manager (noscript) --> 3608 <noscript> 3609 <iframe src="https://www.googletagmanager.com/ns.html?id=@GoogleTagManagerID" 3610 height="0" width="0" style="display:none;visibility:hidden"></iframe> 3611 </noscript> 3612 <!-- End Google Tag Manager (noscript) --> 3613 } 3614 3615 @helper RenderFacebookPixel() 3616 { 3617 string FacebookPixelID = Model.Area.Item.GetItem("Settings").GetString("FacebookPixelID"); 3618 3619 if (!string.IsNullOrWhiteSpace(FacebookPixelID)) 3620 { 3621 <!-- Facebook Pixel Code --> 3622 <script> 3623 !function(f,b,e,v,n,t,s) 3624 {if(f.fbq)return;n=f.fbq=function(){n.callMethod? 3625 n.callMethod.apply(n,arguments):n.queue.push(arguments)}; 3626 if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; 3627 n.queue=[];t=b.createElement(e);t.async=!0; 3628 t.src=v;s=b.getElementsByTagName(e)[0]; 3629 s.parentNode.insertBefore(t,s)}(window, document,'script', 3630 'https://connect.facebook.net/en_US/fbevents.js'); 3631 fbq('init', '@FacebookPixelID'); 3632 fbq('track', 'PageView'); 3633 </script> 3634 <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=@FacebookPixelID&ev=PageView&noscript=1" alt="" /></noscript> 3635 } 3636 } 3637 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3638 3639 @using System 3640 @using System.Web 3641 @using System.Collections.Generic 3642 @using Dynamicweb.Rapido.Blocks 3643 @using Dynamicweb.Rapido.Blocks.Extensibility 3644 @using Dynamicweb.Security.UserManagement 3645 @using Dynamicweb.Security.UserManagement.ExternalAuthentication 3646 @using Dynamicweb.Rapido.Blocks.Components.General 3647 3648 @{ 3649 BlocksPage loginBlocksPage = BlocksPage.GetBlockPage("Master"); 3650 3651 Block loginModal = new Block() 3652 { 3653 Id = "LoginModal", 3654 SortId = 10, 3655 Component = new Modal 3656 { 3657 Id = "SignIn", 3658 Heading = new Heading 3659 { 3660 Level = 0, 3661 Title = Translate("Sign in") 3662 }, 3663 Width = ModalWidth.Sm, 3664 BodyTemplate = RenderLoginForm() 3665 } 3666 }; 3667 3668 loginBlocksPage.Add(MasterBlockId.MasterTopSnippets, loginModal); 3669 } 3670 3671 @helper RenderLoginForm() 3672 { 3673 int pageId = Model.TopPage.ID; 3674 string userSignedInErrorText = ""; 3675 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 3676 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery"; 3677 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount"); 3678 bool showModalOnStart = pageId != GetPageIdByNavigationTag("CustomerCenter") && Model.LogOnFailed; 3679 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount"); 3680 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink"); 3681 3682 ProviderCollection providers = Provider.GetActiveProviders(); 3683 3684 if (Model.LogOnFailed) 3685 { 3686 switch (Model.LogOnFailedReason) 3687 { 3688 case LogOnFailedReason.PasswordLengthInvalid: 3689 userSignedInErrorText = Translate("Password length is invalid"); 3690 break; 3691 case LogOnFailedReason.IncorrectLogin: 3692 userSignedInErrorText = Translate("Invalid email or password"); 3693 break; 3694 case LogOnFailedReason.ExceededFailedLogOnLimit: 3695 userSignedInErrorText = Translate("You have exceeded the limit of allowed login attempts. The user account is temporarily locked"); 3696 break; 3697 case LogOnFailedReason.LoginLocked: 3698 userSignedInErrorText = Translate("The user account is temporarily locked"); 3699 break; 3700 case LogOnFailedReason.PasswordExpired: 3701 userSignedInErrorText = Translate("The password has expired and needs to be renewed"); 3702 break; 3703 default: 3704 userSignedInErrorText = Translate("An unknown error occured"); 3705 break; 3706 } 3707 } 3708 3709 Form form = new Form { Method = FormMethod.Post, Name = "LoginModalForm" }; 3710 3711 TextField passwordField = new TextField { Id = "login-password", Type = TextFieldType.Password, Name = "password", Label = Translate("Password"), Required = true }; 3712 3713 if (!hideForgotPasswordLink) { 3714 passwordField.Link = new Link { Title = Translate("Forgot password?"), Href = "/Default.aspx?id=" + signInProfilePageId + "&LoginAction=Recovery" }; 3715 } 3716 3717 form.Add(new HiddenField { Name = "ID", Value = Converter.ToString(pageId) }); 3718 form.Add(new HiddenField { Name = "DWExtranetUsernameRemember", Value = "True" }); 3719 form.Add(new HiddenField { Name = "DWExtranetPasswordRemember", Value = "True" }); 3720 form.Add(new HiddenField { Name = "LoginAction", Value = "Login" }); 3721 form.Add(new TextField { Id = "LoginUsername", Name = "username", Label = Translate("Email"), CssClass = "u-full-width", Required = true }); 3722 form.Add(passwordField); 3723 form.Add(new NotificationMessage { Message = userSignedInErrorText, MessageType = NotificationMessageType.Error }); 3724 form.Add(new CheckboxField { Id = "LoginRememberMe", Value = "True", Name = "Autologin", Label = Translate("Remember me") }); 3725 form.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Sign in"), CssClass = "btn--full", OnClick = "Buttons.LockButton(event)" }); 3726 3727 foreach (Provider LoginProvider in providers) 3728 { 3729 var ProviderName = LoginProvider.Name.ToLower(); 3730 form.Add(new Link { 3731 Href = "/Admin/Public/Social/ExternalLogin.aspx?action=login&providerID=" + LoginProvider.ID, 3732 Icon = new Icon { Prefix = "fab", Name = "fa-" + ProviderName, CssClass = "fa-1_5x", LabelPosition = IconLabelPosition.After }, 3733 ButtonLayout = ButtonLayout.LinkClean, 3734 CssClass = "btn--condensed u-margin-bottom u-margin-right u-inline-block u-color-" + ProviderName, 3735 AltText = ProviderName 3736 }); 3737 } 3738 3739 if (!hideCreateAccountLink) { 3740 form.Add(new Text { Content = "<div class=\"u-border-top u-full-width u-margin-bottom--lg\"></div>" }); 3741 form.Add(new Link 3742 { 3743 Href = "/Default.aspx?id=" + createAccountPageId, 3744 ButtonLayout = ButtonLayout.LinkClean, 3745 Title = Translate("Create account"), 3746 CssClass = "u-full-width u-ta-center" 3747 }); 3748 } 3749 3750 @Render(form) 3751 3752 if (showModalOnStart) 3753 { 3754 <script> 3755 document.getElementById("SignInModalTrigger").checked = true; 3756 </script> 3757 } 3758 } 3759 3760 @if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet") 3761 { 3762 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3763 3764 @using System 3765 @using System.Web 3766 @using System.Collections.Generic 3767 @using Dynamicweb.Rapido.Blocks.Extensibility 3768 @using Dynamicweb.Rapido.Blocks 3769 @using Dynamicweb.Rapido.Services 3770 3771 3772 @functions { 3773 BlocksPage mobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master"); 3774 } 3775 3776 @{ 3777 var mobileTopLayout = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetString("Design")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left"; 3778 bool mobileHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 3779 bool mobileHideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart") || !Dynamicweb.Rapido.Services.User.IsBuyingAllowed(); 3780 3781 Block mobileHeader = new Block() 3782 { 3783 Id = "MobileTop", 3784 SortId = 10, 3785 Template = RenderMobileTop(), 3786 SkipRenderBlocksList = true 3787 }; 3788 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeader); 3789 3790 Block mobileHeaderNavigation = new Block() 3791 { 3792 Id = "MobileHeaderNavigation", 3793 SortId = 10, 3794 Template = RenderMobileHeaderNavigation(), 3795 SkipRenderBlocksList = true, 3796 BlocksList = new List<Block> { 3797 new Block { 3798 Id = "MobileHeaderNavigationTrigger", 3799 SortId = 10, 3800 Template = RenderMobileHeaderNavigationTrigger() 3801 } 3802 } 3803 }; 3804 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderNavigation); 3805 3806 Block mobileHeaderLogo = new Block() 3807 { 3808 Id = "MobileHeaderLogo", 3809 SortId = 20, 3810 Template = RenderMobileHeaderLogo(), 3811 SkipRenderBlocksList = true 3812 }; 3813 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderLogo); 3814 3815 Block mobileHeaderActions = new Block() 3816 { 3817 Id = "MobileHeaderActions", 3818 SortId = 30, 3819 Template = RenderMobileTopActions(), 3820 SkipRenderBlocksList = true 3821 }; 3822 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderActions); 3823 3824 if (!mobileHideSearch) 3825 { 3826 Block mobileHeaderSearch = new Block 3827 { 3828 Id = "MobileHeaderSearch", 3829 SortId = 10, 3830 Template = RenderMobileTopSearch() 3831 }; 3832 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderSearch); 3833 } 3834 3835 Block mobileHeaderMiniCart; 3836 3837 if (!mobileHideCart) 3838 { 3839 mobileHeaderMiniCart = new Block 3840 { 3841 Id = "MobileHeaderMiniCart", 3842 SortId = 20, 3843 Template = RenderMobileTopMiniCart() 3844 }; 3845 3846 Block miniCartCounterScriptTemplate = new Block 3847 { 3848 Id = "MiniCartCounterScriptTemplate", 3849 Template = RenderMobileMiniCartCounterContent() 3850 }; 3851 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate); 3852 } 3853 else 3854 { 3855 mobileHeaderMiniCart = new Block 3856 { 3857 Id = "MobileHeaderMiniCart", 3858 SortId = 20 3859 }; 3860 } 3861 3862 if (!mobileHideSearch) 3863 { 3864 Block mobileHeaderSearchBar = new Block() 3865 { 3866 Id = "MobileHeaderSearchBar", 3867 SortId = 30, 3868 Template = RenderMobileTopSearchBar() 3869 }; 3870 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeaderSearchBar); 3871 } 3872 3873 switch (mobileTopLayout) 3874 { 3875 case "nav-left": 3876 mobileHeaderNavigation.SortId = 10; 3877 mobileHeaderLogo.SortId = 20; 3878 mobileHeaderActions.SortId = 30; 3879 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart); 3880 break; 3881 case "nav-right": 3882 mobileHeaderLogo.SortId = 10; 3883 mobileHeaderActions.SortId = 20; 3884 mobileHeaderNavigation.SortId = 30; 3885 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart); 3886 break; 3887 case "nav-search-left": 3888 mobileHeaderNavigation.SortId = 10; 3889 mobileHeaderLogo.SortId = 20; 3890 mobileHeaderActions.SortId = 30; 3891 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart); 3892 break; 3893 case "search-left": 3894 mobileHeaderActions.SortId = 10; 3895 mobileHeaderLogo.SortId = 20; 3896 mobileHeaderNavigation.SortId = 30; 3897 mobileHeaderMiniCart.SortId = 0; 3898 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart); 3899 break; 3900 } 3901 } 3902 3903 3904 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3905 3906 @using System 3907 @using System.Web 3908 @using Dynamicweb.Rapido.Blocks.Extensibility 3909 @using Dynamicweb.Rapido.Blocks 3910 3911 @{ 3912 BlocksPage customMobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master"); 3913 } 3914 3915 3916 3917 3918 @helper RenderMobileTop() { 3919 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileTop").OrderBy(item => item.SortId).ToList(); 3920 3921 <nav class="main-navigation-mobile dw-mod"> 3922 <div class="center-container top-container__center-container dw-mod"> 3923 <div class="grid grid--align-center"> 3924 @RenderBlockList(subBlocks) 3925 3926 </div> 3927 </div> 3928 </nav> 3929 } 3930 3931 @helper RenderMobileHeaderNavigation() { 3932 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderNavigation").OrderBy(item => item.SortId).ToList(); 3933 3934 <div class="grid__col-auto-width"> 3935 <ul class="menu dw-mod"> 3936 3937 @RenderBlockList(subBlocks) 3938 3939 </ul> 3940 </div> 3941 } 3942 3943 @helper RenderMobileHeaderNavigationTrigger() { 3944 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 3945 3946 <label for="MobileNavTrigger" class="mobile-nav-trigger-button menu__link menu__link--icon menu__link--mobile dw-mod"></label> 3947 </li> 3948 } 3949 3950 @helper RenderMobileHeaderLogo() { 3951 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderLogo").OrderBy(item => item.SortId).ToList(); 3952 3953 var mobileTopLayout = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetString("Design")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left"; 3954 string centeredLogo = mobileTopLayout != "nav-right" ? "u-ta-center" : ""; 3955 string firstPageId = Model.Area.FirstActivePage.ID.ToString(); 3956 string businessName = Model.Area.Item.GetItem("Settings").GetString("BusinessName"); 3957 3958 string mobileLogo = "/Files/Images/logo-dynamicweb.png"; 3959 if (Model.Area.Item.GetItem("Layout").GetItem("MobileTop") != null && Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo") != null) 3960 { 3961 mobileLogo = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo").PathUrlEncoded; 3962 } 3963 3964 if (Path.GetExtension(mobileLogo).ToLower() != ".svg") 3965 { 3966 mobileLogo = "/Admin/Public/GetImage.ashx?height=40&amp;width=100&amp;crop=5&amp;Compression=75&amp;image=" + mobileLogo; 3967 } 3968 else 3969 { 3970 mobileLogo = HttpUtility.UrlDecode(mobileLogo); 3971 } 3972 3973 <div class="grid__col-auto grid__col--bleed"> 3974 <div class="grid__cell @centeredLogo"> 3975 <a href="/Default.aspx?ID=@firstPageId" class="logo logo--mobile u-inline-block dw-mod"> 3976 <img class="grid__cell-img logo__img logo__img--mobile dw-mod" src="@mobileLogo" alt="@businessName" /> 3977 </a> 3978 </div> 3979 3980 @RenderBlockList(subBlocks) 3981 </div> 3982 } 3983 3984 @helper RenderMobileTopActions() { 3985 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderActions").OrderBy(item => item.SortId).ToList(); 3986 3987 <div class="grid__col-auto-width"> 3988 <ul class="menu dw-mod"> 3989 @RenderBlockList(subBlocks) 3990 3991 </ul> 3992 </div> 3993 } 3994 3995 @helper RenderMobileTopSearch() { 3996 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 3997 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod"> 3998 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i> 3999 4000 </label> 4001 </li> 4002 } 4003 4004 @helper RenderMobileTopMiniCart() { 4005 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 4006 int cartPageId = GetPageIdByNavigationTag("CartPage"); 4007 double cartProductsCount = Model.Cart.TotalProductsCount; 4008 4009 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod" id="miniCartWrapper"> 4010 <div class="mini-cart dw-mod"> 4011 <a href="/Default.aspx?ID=@cartPageId&Purge=True" id="miniCartCounterWrap" class="menu__link menu__link--icon menu__link--mobile dw-mod js-mini-cart-button"> 4012 <div class="u-inline u-position-relative"> 4013 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue fa-1_5x"></i> 4014 <div class="mini-cart__counter dw-mod"> 4015 <div class="js-handlebars-root js-mini-cart-counter" id="cartCounter" data-template="MiniCartCounterContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=Counter" data-init-onload="false" data-preloader="false"> 4016 <div class="js-mini-cart-counter-content" data-count="@cartProductsCount"> 4017 @cartProductsCount 4018 </div> 4019 </div> 4020 </div> 4021 </div> 4022 </a> 4023 </div> 4024 </li> 4025 } 4026 4027 @helper RenderMobileTopSearchBar() 4028 { 4029 string searchFeedId = ""; 4030 string searchSecondFeedId = ""; 4031 int groupsFeedId; 4032 int productsPageId = GetPageIdByNavigationTag("ProductsPage"); 4033 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 4034 string resultPageLink; 4035 string searchPlaceholder; 4036 string searchType = "product-search"; 4037 string searchTemplate; 4038 string searchContentTemplate = ""; 4039 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 4040 bool showGroups = true; 4041 4042 if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "contentSearch") 4043 { 4044 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true"; 4045 resultPageLink = contentSearchPageLink; 4046 searchPlaceholder = Translate("Search page"); 4047 groupsFeedId = 0; 4048 searchType = "content-search"; 4049 searchTemplate = "SearchPagesTemplate"; 4050 showGroups = false; 4051 } 4052 else if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "combinedSearch") 4053 { 4054 searchFeedId = productsPageId + "&feed=true"; 4055 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true"; 4056 resultPageLink = Converter.ToString(productsPageId); 4057 searchPlaceholder = Translate("Search products or pages"); 4058 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"); 4059 searchType = "combined-search"; 4060 searchTemplate = "SearchProductsTemplateWrap"; 4061 searchContentTemplate = "SearchPagesTemplateWrap"; 4062 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector"); 4063 } 4064 else 4065 { 4066 resultPageLink = Converter.ToString(productsPageId); 4067 searchFeedId = productsPageId + "&feed=true"; 4068 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"); 4069 searchPlaceholder = Translate("Search products"); 4070 searchTemplate = "SearchProductsTemplate"; 4071 searchType = "product-search"; 4072 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector"); 4073 } 4074 4075 <input type="checkbox" id="MobileSearchTrigger" class="mobile-search-trigger" /> 4076 4077 <div class="main-navigation-mobile typeahead-mobile dw-mod"> 4078 <div class="center-container top-container__center-container dw-mod"> 4079 <div class="grid"> 4080 <div class="grid__col-auto"> 4081 <div class="typeahead-mobile__search-field dw-mod js-typeahead" data-page-size="@(searchType == "combined-search" ? 4 : 8)" id="MobileProductSearch" data-search-feed-id="@searchFeedId" data-search-second-feed-id="@searchSecondFeedId" data-result-page-id="@resultPageLink" data-search-type="@searchType"> 4082 <input type="text" class="js-typeahead-search-field u-w160px u-no-margin" placeholder="@searchPlaceholder" value="@searchValue"> 4083 @if (string.IsNullOrEmpty(searchSecondFeedId)) 4084 { 4085 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="MobileProductSearchBarContent" data-template="@searchTemplate" data-json-feed="/Default.aspx?ID=@searchFeedId&feedType=productsOnly" data-init-onload="false"></ul> 4086 } 4087 else 4088 { 4089 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--combined-mobile grid"> 4090 <div class="js-handlebars-root js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="MobileProductSearchBarContent" data-template="@searchTemplate" data-json-feed="/Default.aspx?ID=@searchFeedId&feedType=productsOnly" data-init-onload="false"></div> 4091 <div class="js-handlebars-root js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="MobileContentSearchBarContent" data-template="@searchContentTemplate" data-json-feed="/Default.aspx?ID=@searchSecondFeedId" data-init-onload="false"></div> 4092 </div> 4093 } 4094 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue"></i></button> 4095 </div> 4096 </div> 4097 <div class="grid__col-auto-width"> 4098 <ul class="menu dw-mod"> 4099 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod"> 4100 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod"> 4101 <i class="fas fa-times fa-1_5x"></i> 4102 </label> 4103 </li> 4104 </ul> 4105 </div> 4106 </div> 4107 </div> 4108 </div> 4109 } 4110 4111 @helper RenderMobileMiniCartCounterContent() 4112 { 4113 <script id="MiniCartCounterContent" type="text/x-template"> 4114 {{#.}} 4115 <div class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}"> 4116 {{numberofproducts}} 4117 </div> 4118 {{/.}} 4119 </script> 4120 } 4121 </text> 4122 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4123 4124 @using System 4125 @using System.Web 4126 @using System.Collections.Generic 4127 @using Dynamicweb.Rapido.Blocks.Extensibility 4128 @using Dynamicweb.Rapido.Blocks 4129 4130 @functions { 4131 BlocksPage mobileNavigationBlocksPage = BlocksPage.GetBlockPage("Master"); 4132 } 4133 4134 @{ 4135 bool mobileNavigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn"); 4136 bool mobileHideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount"); 4137 bool mobileHideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile"); 4138 bool mobileHideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders"); 4139 bool mobileHideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards"); 4140 bool mobileHideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites"); 4141 4142 Block mobileNavigation = new Block() 4143 { 4144 Id = "MobileNavigation", 4145 SortId = 10, 4146 Template = MobileNavigation(), 4147 SkipRenderBlocksList = true 4148 }; 4149 mobileNavigationBlocksPage.Add(MasterBlockId.MasterTopSnippets, mobileNavigation); 4150 4151 if (Model.CurrentUser.ID > 0 && !mobileHideMyProfileLink) 4152 { 4153 Block mobileNavigationSignIn = new Block 4154 { 4155 Id = "MobileNavigationSignIn", 4156 SortId = 10, 4157 Template = RenderMobileNavigationSignIn() 4158 }; 4159 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationSignIn); 4160 } 4161 4162 Block mobileNavigationMenu = new Block 4163 { 4164 Id = "MobileNavigationMenu", 4165 SortId = 20, 4166 Template = RenderMobileNavigationMenu() 4167 }; 4168 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationMenu); 4169 4170 Block mobileNavigationActions = new Block 4171 { 4172 Id = "MobileNavigationActions", 4173 SortId = 30, 4174 Template = RenderMobileNavigationActions(), 4175 SkipRenderBlocksList = true 4176 }; 4177 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationActions); 4178 4179 if (!mobileNavigationItemsHideSignIn) 4180 { 4181 if (Model.CurrentUser.ID <= 0) 4182 { 4183 Block mobileNavigationSignInAction = new Block 4184 { 4185 Id = "MobileNavigationSignInAction", 4186 SortId = 10, 4187 Template = RenderMobileNavigationSignInAction() 4188 }; 4189 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignInAction); 4190 4191 if (!mobileHideCreateAccountLink) 4192 { 4193 Block mobileNavigationCreateAccountAction = new Block 4194 { 4195 Id = "MobileNavigationCreateAccountAction", 4196 SortId = 20, 4197 Template = RenderMobileNavigationCreateAccountAction() 4198 }; 4199 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationCreateAccountAction); 4200 } 4201 } 4202 else 4203 { 4204 if (!mobileHideMyOrdersLink) 4205 { 4206 Block mobileNavigationOrdersAction = new Block 4207 { 4208 Id = "MobileNavigationOrdersAction", 4209 SortId = 20, 4210 Template = RenderMobileNavigationOrdersAction() 4211 }; 4212 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationOrdersAction); 4213 } 4214 if (!mobileHideMyFavoritesLink) 4215 { 4216 Block mobileNavigationFavoritesAction = new Block 4217 { 4218 Id = "MobileNavigationFavoritesAction", 4219 SortId = 30, 4220 Template = RenderMobileNavigationFavoritesAction() 4221 }; 4222 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationFavoritesAction); 4223 } 4224 if (!mobileHideMySavedCardsLink) 4225 { 4226 Block mobileNavigationSavedCardsAction = new Block 4227 { 4228 Id = "MobileNavigationFavoritesAction", 4229 SortId = 30, 4230 Template = RenderMobileNavigationSavedCardsAction() 4231 }; 4232 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSavedCardsAction); 4233 } 4234 4235 Block mobileNavigationSignOutAction = new Block 4236 { 4237 Id = "MobileNavigationSignOutAction", 4238 SortId = 40, 4239 Template = RenderMobileNavigationSignOutAction() 4240 }; 4241 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignOutAction); 4242 } 4243 } 4244 4245 if (Model.Languages.Count > 1) 4246 { 4247 Block mobileNavigationLanguagesAction = new Block 4248 { 4249 Id = "MobileNavigationLanguagesAction", 4250 SortId = 50, 4251 Template = RenderMobileNavigationLanguagesAction() 4252 }; 4253 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationLanguagesAction); 4254 } 4255 } 4256 4257 4258 @helper MobileNavigation() 4259 { 4260 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigation").OrderBy(item => item.SortId).ToList(); 4261 string mobileTopDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design") != null ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left"; 4262 string position = mobileTopDesign == "nav-left" || mobileTopDesign == "nav-search-left" ? "left" : "right"; 4263 4264 <!-- Trigger for mobile navigation --> 4265 <input type="checkbox" id="MobileNavTrigger" class="mobile-nav-trigger mobile-nav-trigger--@position" autocomplete="off" /> 4266 4267 <!-- Mobile navigation --> 4268 <nav class="mobile-navigation mobile-navigation--@position dw-mod"> 4269 <div class="mobile-navigation__wrapper" id="mobileNavigationWrapper"> 4270 @RenderBlockList(subBlocks) 4271 @*<a href="/english/request-for-quotation"><button class="button button4" style="position: relative;top: 6px;width:295px;">Request for Quotation</button></a>*@ 4272 </div> 4273 </nav> 4274 4275 <label class="mobile-nav-trigger-off" for="MobileNavTrigger"></label> 4276 4277 } 4278 4279 @helper RenderMobileNavigationSignIn() 4280 { 4281 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4282 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile"); 4283 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4284 string myProfilePageLink = linkStart + myProfilePageId; 4285 string userName = Model.CurrentUser.FirstName; 4286 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(Model.CurrentUser.LastName)) 4287 { 4288 userName += " " + Model.CurrentUser.LastName; 4289 } 4290 if (string.IsNullOrEmpty(userName)) 4291 { 4292 userName = Model.CurrentUser.Name; 4293 } 4294 if (string.IsNullOrEmpty(userName)) 4295 { 4296 userName = Model.CurrentUser.UserName; 4297 } 4298 if (string.IsNullOrEmpty(userName)) 4299 { 4300 userName = Model.CurrentUser.Email; 4301 } 4302 4303 <ul class="menu menu-mobile"> 4304 <li class="menu-mobile__item"> 4305 <a href="@myProfilePageLink" class="menu-mobile__link dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @userName</a> 4306 </li> 4307 </ul> 4308 } 4309 4310 @helper RenderMobileNavigationMenu() 4311 { 4312 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides"; 4313 string menuTemplate = isSlidesDesign ? "BaseMenuForMobileSlides.xslt" : "BaseMenuForMobileExpandable.xslt"; 4314 string levels = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels") : "3"; 4315 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 4316 int startLevel = 0; 4317 4318 @RenderNavigation(new 4319 { 4320 id = "mobilenavigation", 4321 cssclass = "menu menu-mobile dwnavigation", 4322 startLevel = @startLevel, 4323 ecomStartLevel = @startLevel + 1, 4324 endlevel = @levels, 4325 expandmode = "all", 4326 template = @menuTemplate 4327 }) 4328 4329 if (isSlidesDesign) 4330 { 4331 <script> 4332 function goToLevel(level) { 4333 document.getElementById('mobileNavigationWrapper').style.left = -(level * 100) + "%"; 4334 } 4335 4336 document.addEventListener('DOMContentLoaded', function () { 4337 goToLevel(document.getElementById('mobileNavigationWrapper').querySelectorAll('input[type=radio]:checked').length); 4338 }); 4339 </script> 4340 } 4341 4342 if (renderPagesInToolBar) 4343 { 4344 @RenderNavigation(new 4345 { 4346 id = "topToolsMobileNavigation", 4347 cssclass = "menu menu-mobile dwnavigation", 4348 template = "ToolsMenuForMobile.xslt" 4349 }) 4350 } 4351 } 4352 4353 @helper RenderMobileNavigationActions() 4354 { 4355 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigationActions").OrderBy(item => item.SortId).ToList(); ; 4356 4357 <ul class="menu menu-mobile"> 4358 @RenderBlockList(subBlocks) 4359 4360 </ul> 4361 } 4362 4363 @helper RenderMobileNavigationSignInAction() 4364 { 4365 <li class="menu-mobile__item"> 4366 <label for="SignInModalTrigger" onclick="document.getElementById('MobileNavTrigger').checked = false;" class="menu-mobile__link dw-mod menu-mobile__link--highlighted"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("Sign in")</label> 4367 </li> 4368 } 4369 4370 @helper RenderMobileNavigationCreateAccountAction() 4371 { 4372 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount"); 4373 4374 <li class="menu-mobile__item"> 4375 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod" href="/Default.aspx?ID=@createAccountPageId"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("Create account")</a> 4376 </li> 4377 } 4378 4379 @helper RenderMobileNavigationProfileAction() 4380 { 4381 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4382 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4383 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile"); 4384 string myProfilePageLink = linkStart + myProfilePageId; 4385 4386 <li class="menu-mobile__item"> 4387 <a href="@myProfilePageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("My Profile")</a> 4388 </li> 4389 } 4390 4391 @helper RenderMobileNavigationOrdersAction() 4392 { 4393 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4394 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4395 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders"); 4396 string myOrdersPageLink = linkStart + myOrdersPageId; 4397 string ordersIcon = "fas fa-list"; 4398 4399 <li class="menu-mobile__item"> 4400 <a href="@myOrdersPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@ordersIcon menu-mobile__link-icon"></i> @Translate("My Orders")</a> 4401 </li> 4402 } 4403 4404 @helper RenderMobileNavigationFavoritesAction() 4405 { 4406 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4407 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4408 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 4409 string myFavoritesPageLink = linkStart + myFavoritesPageId; 4410 string favoritesIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "fa fa-star"; 4411 4412 4413 <li class="menu-mobile__item"> 4414 <a href="@myFavoritesPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@favoritesIcon menu-mobile__link-icon"></i> @Translate("My Favorites")</a> 4415 </li> 4416 } 4417 4418 @helper RenderMobileNavigationSavedCardsAction() 4419 { 4420 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4421 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID="; 4422 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards"); 4423 string mySavedCardsPageLink = linkStart + mySavedCardsPageId; 4424 string savedCardsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SavedCards") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SavedCards").SelectedValue : "fas fa-credit-card"; 4425 4426 <li class="menu-mobile__item"> 4427 <a href="@mySavedCardsPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@savedCardsIcon menu-mobile__link-icon"></i> @Translate("My Saved Cards")</a> 4428 </li> 4429 } 4430 4431 @helper RenderMobileNavigationSignOutAction() 4432 { 4433 int pageId = Model.TopPage.ID; 4434 string signOutIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignOutIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignOutIcon").SelectedValue : "far fa-sign-out-alt"; 4435 4436 <li class="menu-mobile__item"> 4437 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod" href="/Admin/Public/ExtranetLogoff.aspx?ID=@pageId" onclick="RememberState.SetCookie('useAnotherAddress', false)"><i class="@signOutIcon menu-mobile__link-icon"></i> @Translate("Sign out")</a> 4438 </li> 4439 } 4440 4441 @helper RenderMobileNavigationLanguagesAction() 4442 { 4443 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides"; 4444 4445 string selectedLanguage = ""; 4446 foreach (var lang in Model.Languages) 4447 { 4448 if (lang.IsCurrent) 4449 { 4450 selectedLanguage = lang.Name; 4451 } 4452 } 4453 4454 <li class="menu-mobile__item dw-mod"> 4455 @if (isSlidesDesign) 4456 { 4457 <input id="MobileMenuCheck_Language" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(1);"> 4458 } 4459 else 4460 { 4461 <input id="MobileMenuCheck_Language" type="checkbox" class="expand-trigger"> 4462 } 4463 <div class="menu-mobile__link__wrap"> 4464 <label for="MobileMenuCheck_Language" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue menu-mobile__link-icon"></i> @selectedLanguage</label> 4465 <label for="MobileMenuCheck_Language" class="menu-mobile__trigger"></label> 4466 </div> 4467 <ul class="menu-mobile menu-mobile__submenu expand-menu"> 4468 @if (isSlidesDesign) 4469 { 4470 <li class="menu-mobile__item dw-mod"> 4471 <div class="menu-mobile__link__wrap"> 4472 <input id="MobileMenuCheck_Language_back" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(0);" /> 4473 <label for="MobileMenuCheck_Language_back" class="menu-mobile__trigger menu-mobile__trigger--back"></label> 4474 <label for="MobileMenuCheck_Language_back" class="menu-mobile__link dw-mod ">@Translate("Back")</label> 4475 </div> 4476 </li> 4477 } 4478 @foreach (var lang in Model.Languages) 4479 { 4480 <li class="menu-mobile__item dw-mod"> 4481 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod menu-mobile__link--level-1" href="/Default.aspx?ID=@lang.Page.ID">@lang.Name</a> 4482 </li> 4483 } 4484 </ul> 4485 </li> 4486 }</text> 4487 } 4488 else 4489 { 4490 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4491 4492 @using System 4493 @using System.Web 4494 @using System.Collections.Generic 4495 @using Dynamicweb.Rapido.Blocks.Extensibility 4496 @using Dynamicweb.Rapido.Blocks 4497 4498 @functions { 4499 BlocksPage headerBlocksPage = BlocksPage.GetBlockPage("Master"); 4500 } 4501 4502 @{ 4503 Block masterTools = new Block() 4504 { 4505 Id = "MasterDesktopTools", 4506 SortId = 10, 4507 Template = RenderDesktopTools(), 4508 SkipRenderBlocksList = true, 4509 BlocksList = new List<Block> 4510 { 4511 new Block { 4512 Id = "MasterDesktopToolsText", 4513 SortId = 10, 4514 Template = RenderDesktopToolsText(), 4515 Design = new Design 4516 { 4517 Size = "auto", 4518 HidePadding = true, 4519 RenderType = RenderType.Column 4520 } 4521 }, 4522 new Block { 4523 Id = "MasterDesktopToolsNavigation", 4524 SortId = 20, 4525 Template = RenderDesktopToolsNavigation(), 4526 Design = new Design 4527 { 4528 Size = "auto-width", 4529 HidePadding = true, 4530 RenderType = RenderType.Column 4531 } 4532 } 4533 } 4534 }; 4535 headerBlocksPage.Add("MasterHeader", masterTools); 4536 4537 Block masterDesktopExtra = new Block() 4538 { 4539 Id = "MasterDesktopExtra", 4540 SortId = 10, 4541 Template = RenderDesktopExtra(), 4542 SkipRenderBlocksList = true 4543 }; 4544 headerBlocksPage.Add("MasterHeader", masterDesktopExtra); 4545 4546 Block masterDesktopNavigation = new Block() 4547 { 4548 Id = "MasterDesktopNavigation", 4549 SortId = 20, 4550 Template = RenderDesktopNavigation(), 4551 SkipRenderBlocksList = true 4552 }; 4553 headerBlocksPage.Add("MasterHeader", masterDesktopNavigation); 4554 } 4555 4556 @* Include the Blocks for the page *@ 4557 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4558 4559 @using System 4560 @using System.Web 4561 @using Dynamicweb.Rapido.Blocks.Extensibility 4562 @using Dynamicweb.Rapido.Blocks 4563 4564 @{ 4565 Block masterDesktopLogo = new Block 4566 { 4567 Id = "MasterDesktopLogo", 4568 SortId = 10, 4569 Template = RenderDesktopLogo(), 4570 Design = new Design 4571 { 4572 Size = "auto-width", 4573 HidePadding = true, 4574 RenderType = RenderType.Column, 4575 CssClass = "grid--align-self-center" 4576 } 4577 }; 4578 4579 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopLogo); 4580 } 4581 4582 4583 @helper RenderDesktopLogo() 4584 { 4585 string firstPageId = Model.Area.FirstActivePage.ID.ToString(); 4586 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4587 string alignClass = topLayout == "two-lines-centered" || topLayout == "two-lines" ? "grid--align-self-center" : ""; 4588 alignClass = topLayout == "splitted-center" ? "u-middle" : alignClass; 4589 string logo = Model.Area.Item.GetItem("Layout").GetFile("LogoImage") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoImage").PathUrlEncoded : "/Files/Images/logo-dynamicweb.png"; 4590 if (Path.GetExtension(logo).ToLower() != ".svg") 4591 { 4592 int logoHeight = Model.Area.Item.GetItem("Layout").GetInt32("LogoHeight"); 4593 logoHeight = logoHeight > 0 && Pageview.Device.ToString() != "Mobile" ? logoHeight : 40; 4594 logo = "/Admin/Public/GetImage.ashx?height=" + Converter.ToString(logoHeight) + "&amp;crop=5&amp;Compression=75&amp;image=" + logo; 4595 } 4596 else 4597 { 4598 logo = HttpUtility.UrlDecode(logo); 4599 } 4600 4601 <div class="logo @alignClass dw-mod"> 4602 <a href="/Default.aspx?ID=@firstPageId" class="logo__img dw-mod u-block"> 4603 <img class="grid__cell-img logo__img dw-mod" src="@logo" alt="@Translate("Logo")" /> 4604 </a> 4605 </div> 4606 } 4607 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4608 4609 @using System 4610 @using System.Web 4611 @using Dynamicweb.Rapido.Blocks.Extensibility 4612 @using Dynamicweb.Rapido.Blocks 4613 4614 @functions { 4615 bool isMegaMenu; 4616 } 4617 4618 @{ 4619 isMegaMenu = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu") != null ? Converter.ToBoolean(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu").SelectedValue) : false; 4620 Block masterDesktopMenu = new Block 4621 { 4622 Id = "MasterDesktopMenu", 4623 SortId = 10, 4624 Template = RenderDesktopMenu(), 4625 Design = new Design 4626 { 4627 Size = "auto", 4628 HidePadding = true, 4629 RenderType = RenderType.Column 4630 } 4631 }; 4632 4633 if (isMegaMenu) 4634 { 4635 masterDesktopMenu.Design.CssClass = "u-reset-position"; 4636 } 4637 4638 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopMenu); 4639 } 4640 4641 @helper RenderDesktopMenu() 4642 { 4643 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4644 string menuAlignment = topLayout == "minimal-right" ? "grid--align-self-end" : ""; 4645 menuAlignment = topLayout == "minimal-center" ? "grid--align-self-center" : topLayout; 4646 string megamenuPromotionImage = Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage").PathUrlEncoded : ""; 4647 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 4648 bool showOnlyHeaders = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOnlyHeaders"); 4649 int startLevel = renderPagesInToolBar ? 1 : 0; 4650 4651 string promotionLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("MegamenuPromotionLink"); 4652 4653 <div class="grid__cell u-flex @(isMegaMenu ? "u-reset-position" : "") @menuAlignment"> 4654 @if (!isMegaMenu) 4655 { 4656 @RenderNavigation(new 4657 { 4658 id = "topnavigation", 4659 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap", 4660 startLevel = startLevel, 4661 ecomStartLevel = startLevel + 1, 4662 endlevel = 5, 4663 expandmode = "all", 4664 template = "BaseMenuWithDropdown.xslt" 4665 }); 4666 } 4667 else 4668 { 4669 @RenderNavigation(new 4670 { 4671 id = "topnavigation", 4672 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap", 4673 startLevel = startLevel, 4674 ecomStartLevel = startLevel + 1, 4675 endlevel = 5, 4676 promotionImage = megamenuPromotionImage, 4677 promotionLink = promotionLink, 4678 expandmode = "all", 4679 showOnlyHeaders = showOnlyHeaders.ToString().ToLower(), 4680 template = "BaseMegaMenu.xslt" 4681 }); 4682 } 4683 </div> 4684 } 4685 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4686 4687 @using System 4688 @using System.Web 4689 @using Dynamicweb.Rapido.Blocks.Extensibility 4690 @using Dynamicweb.Rapido.Blocks 4691 4692 @{ 4693 Block masterDesktopActionsMenu = new Block 4694 { 4695 Id = "MasterDesktopActionsMenu", 4696 SortId = 10, 4697 Template = RenderDesktopActionsMenu(), 4698 Design = new Design 4699 { 4700 CssClass = "u-flex" 4701 }, 4702 SkipRenderBlocksList = true 4703 4704 }; 4705 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopActionsMenu); 4706 4707 if (!string.IsNullOrWhiteSpace(Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink"))) 4708 { 4709 Block masterDesktopActionsHeaderButton = new Block 4710 { 4711 Id = "MasterDesktopActionsHeaderButton", 4712 SortId = 60, 4713 Template = RenderHeaderButton() 4714 }; 4715 masterDesktopActionsMenu.Add(masterDesktopActionsHeaderButton); 4716 } 4717 } 4718 4719 @helper RenderDesktopActionsMenu() 4720 { 4721 List<Block> subBlocks = this.headerBlocksPage.GetBlockListById("MasterDesktopActionsMenu").OrderBy(item => item.SortId).ToList(); 4722 4723 <ul class="menu u-flex dw-mod"> 4724 @RenderBlockList(subBlocks) 4725 </ul> 4726 } 4727 4728 @helper RenderHeaderButton() 4729 { 4730 string headerButtonText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonText"); 4731 string headerButtonLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink"); 4732 string headerButtonType = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType") != null ? "btn--" + Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType").SelectedName.ToLower() : ""; 4733 4734 <li class="menu__item menu__item--horizontal menu--clean dw-mod"> 4735 <a class="btn @headerButtonType dw-mod u-no-margin u-margin-left" href="@headerButtonLink">@headerButtonText</a> 4736 </li> 4737 } 4738 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4739 4740 @using System 4741 @using System.Web 4742 @using Dynamicweb.Core; 4743 @using System.Text.RegularExpressions 4744 @using Dynamicweb.Rapido.Blocks.Extensibility 4745 @using Dynamicweb.Rapido.Blocks 4746 4747 @{ 4748 Block masterDesktopActionsMenuLanguageSelector = new Block 4749 { 4750 Id = "MasterDesktopActionsMenuLanguageSelector", 4751 SortId = 40, 4752 Template = RenderLanguageSelector() 4753 }; 4754 4755 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuLanguageSelector); 4756 } 4757 4758 @helper RenderLanguageSelector() 4759 { 4760 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4761 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 4762 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 4763 string languageViewType = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("LanguageSelector").SelectedValue) ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("LanguageSelector").SelectedValue.ToLower() : ""; 4764 4765 if (Model.Languages.Count > 1) 4766 { 4767 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon is-dropdown is-dropdown--no-icon dw-mod"> 4768 <div class="@menuLinkClass dw-mod" title="@Translate("Language")"> 4769 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue fa-1_5x"></i> 4770 </div> 4771 <div class="menu menu--dropdown menu--dropdown-right languages-dropdown dw-mod grid__cell"> 4772 @foreach (var lang in Model.Languages) 4773 { 4774 string widthClass = "menu__item--fixed-width"; 4775 string langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " u-margin-right\"></span>" + lang.Name; 4776 string cultureName = Regex.Replace(Dynamicweb.Services.Areas.GetArea(lang.ID).CultureInfo.NativeName, @" ?\(.*?\)", string.Empty); 4777 cultureName = char.ToUpper(cultureName[0]) + cultureName.Substring(1); 4778 4779 if (languageViewType == "flag-culture") 4780 { 4781 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span> " + cultureName; 4782 } 4783 4784 if (languageViewType == "flag") 4785 { 4786 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span>"; 4787 widthClass = ""; 4788 } 4789 4790 if (languageViewType == "name") 4791 { 4792 langInfo = lang.Name; 4793 } 4794 4795 if (languageViewType == "culture") 4796 { 4797 langInfo = cultureName; 4798 widthClass = ""; 4799 } 4800 4801 <div class="menu__item dw-mod @widthClass"> 4802 <a href="/Default.aspx?AreaID=@Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID" class="menu-dropdown__link dw-mod">@langInfo</a> 4803 </div> 4804 } 4805 </div> 4806 </li> 4807 } 4808 } 4809 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4810 4811 @using System 4812 @using System.Web 4813 @using Dynamicweb.Rapido.Blocks.Extensibility 4814 @using Dynamicweb.Rapido.Blocks 4815 4816 @{ 4817 Block masterDesktopActionsMenuSignIn = new Block 4818 { 4819 Id = "MasterDesktopActionsMenuSignIn", 4820 SortId = 20, 4821 Template = RenderSignIn() 4822 }; 4823 4824 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuSignIn); 4825 } 4826 4827 @helper RenderSignIn() 4828 { 4829 bool navigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn"); 4830 string userInitials = ""; 4831 int pageId = Model.TopPage.ID; 4832 int homepageId = GetPageIdByNavigationTag("Frontpage"); 4833 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount"); 4834 int myDashboardPageId = GetPageIdByNavigationTag("CustomerDashboard"); 4835 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile"); 4836 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders"); 4837 int myB2BOrdersPageId = GetPageIdByNavigationTag("B2BOrders"); 4838 int myPOOrdersPageId = GetPageIdByNavigationTag("POOrder"); 4839 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 4840 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards"); 4841 int myOrderDraftsPageId = GetPageIdByNavigationTag("OrderDraft"); 4842 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 4843 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount"); 4844 bool hideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile"); 4845 bool hideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders"); 4846 bool hideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards"); 4847 bool hideMyOrderDraftsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrderDrafts"); 4848 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites"); 4849 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink"); 4850 4851 string linkStart = "/Default.aspx?ID="; 4852 if (Model.CurrentUser.ID <= 0) 4853 { 4854 linkStart += signInProfilePageId + "&RedirectPageId="; 4855 } 4856 4857 var user = Dynamicweb.Security.UserManagement.User.GetUserByID(Model.CurrentUser.ID); 4858 string userType = ""; 4859 string grps = ""; 4860 4861 if (Model.CurrentUser.ID != 0) 4862 { 4863 if (user != null) 4864 { 4865 foreach (var grp in user.Groups) 4866 { 4867 grps = grp.ID.ToString(); 4868 } 4869 if (grps.Contains("144")) 4870 { 4871 userType = "B2C"; 4872 } 4873 else if (grps.Contains("145")) 4874 { 4875 userType = "B2B"; 4876 } 4877 } 4878 } 4879 4880 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery"; 4881 string myProfilePageLink = linkStart + myProfilePageId; 4882 string myOrdersPageLink = linkStart + myOrdersPageId; 4883 string myB2BOrdersPageLink = linkStart + myB2BOrdersPageId; 4884 string myPOOrdersPageLink = linkStart + myPOOrdersPageId; 4885 string myFavoritesPageLink = linkStart + myFavoritesPageId; 4886 string mySavedCardsPageLink = linkStart + mySavedCardsPageId; 4887 string myOrderDraftsLink = linkStart + myOrderDraftsPageId; 4888 4889 string profileIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue : "fa fa-user"; 4890 string favoritesIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "fa fa-star"; 4891 string orderDraftsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard"; 4892 4893 if (Model.CurrentUser.ID != 0) 4894 { 4895 userInitials = Dynamicweb.Rapido.Services.User.GetInitials(Model.CurrentUser.Name, Model.CurrentUser.FirstName, Model.CurrentUser.LastName, Model.CurrentUser.Email, Model.CurrentUser.UserName); 4896 } 4897 4898 if (!navigationItemsHideSignIn) 4899 { 4900 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4901 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu__item--clean"; 4902 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 4903 4904 <li class="menu__item menu__item--horizontal menu__item menu__item--icon @liClasses is-dropdown is-dropdown--no-icon dw-mod"> 4905 <div class="@menuLinkClass dw-mod"> 4906 @if (Model.CurrentUser.ID <= 0) 4907 { 4908 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue fa-1_5x" title="@Translate("Sign in")"></i> 4909 } 4910 else 4911 { 4912 <a href="/default.aspx?ID=@myDashboardPageId" class="u-color-inherit" title="@Translate("Customer center")"><div class="circle-icon-btn">@userInitials.ToUpper()</div></a> 4913 } 4914 </div> 4915 <div class="menu menu--dropdown menu--dropdown-right menu--sign-in grid__cell dw-mod"> 4916 <ul class="list list--clean dw-mod"> 4917 @if (Model.CurrentUser.ID <= 0) 4918 { 4919 <li> 4920 <label for="SignInModalTrigger" class="btn btn--primary btn--full u-no-margin sign-in-modal-trigger-button dw-mod" onclick="setTimeout(function () { document.getElementById('LoginUsername').focus() }, 10)">@Translate("Sign in")</label> 4921 </li> 4922 4923 if (!hideCreateAccountLink) 4924 { 4925 @RenderListItem("/default.aspx?ID=" + createAccountPageId, Translate("Create account")); 4926 } 4927 if (!hideForgotPasswordLink) 4928 { 4929 @RenderListItem(forgotPasswordPageLink, Translate("Forgot your password?")) 4930 } 4931 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink) 4932 { 4933 @RenderSeparator() 4934 } 4935 } 4936 @if (!hideMyProfileLink) 4937 { 4938 @RenderListItem(myProfilePageLink, Translate("My Profile"), profileIcon) 4939 } 4940 @if (!hideMyOrdersLink && userType == "B2B") 4941 { 4942 @RenderListItem(myB2BOrdersPageLink, Translate("My Orders"), "fas fa-list") 4943 } 4944 else if (!hideMyOrdersLink) 4945 { 4946 @RenderListItem(myOrdersPageLink, Translate("My Orders"), "fas fa-list") 4947 } 4948 @if (userType == "B2B") 4949 { 4950 @RenderListItem(myPOOrdersPageLink, Translate("My PO Orders"), "fas fa-list") 4951 } 4952 @if (!hideMyFavoritesLink) 4953 { 4954 @RenderListItem(myFavoritesPageLink, Translate("My Favorites"), favoritesIcon) 4955 } 4956 @if (!hideMySavedCardsLink) 4957 { 4958 @RenderListItem(mySavedCardsPageLink, Translate("My Saved cards"), "fas fa-credit-card") 4959 } 4960 @if (!hideMyOrderDraftsLink) 4961 { 4962 @RenderListItem(myOrderDraftsLink, Translate("My Order drafts"), orderDraftsIcon) 4963 } 4964 @if (Model.CurrentUser.ID > 0) 4965 { 4966 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink) 4967 { 4968 @RenderSeparator() 4969 } 4970 4971 //Check if impersonation is on 4972 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0) 4973 { 4974 <li> 4975 <div class="list__link dw-mod" onclick="document.getElementById('StopImpersonationModalTrigger').checked = true;"> 4976 @Translate("Sign out") 4977 </div> 4978 </li> 4979 } 4980 else 4981 { 4982 @RenderListItem("/Admin/Public/ExtranetLogoff.aspx?ID=" + homepageId, Translate("Sign out")) 4983 } 4984 } 4985 </ul> 4986 </div> 4987 </li> 4988 } 4989 } 4990 4991 @helper RenderListItem(string link, string text, string icon = null) 4992 { 4993 <li> 4994 <a href="@link" class="list__link dw-mod" onclick="RememberState.SetCookie('useAnotherAddress', false)"> 4995 @if (!string.IsNullOrEmpty(icon)) 4996 {<i class="@icon u-margin-right"></i>}@text 4997 </a> 4998 </li> 4999 } 5000 5001 @helper RenderSeparator() 5002 { 5003 <li class="list__seperator dw-mod"></li> 5004 } 5005 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5006 5007 @using System 5008 @using System.Web 5009 @using Dynamicweb.Rapido.Blocks.Extensibility 5010 @using Dynamicweb.Rapido.Blocks 5011 5012 @{ 5013 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideFavorites"); 5014 5015 Block masterDesktopActionsMenuFavorites = new Block 5016 { 5017 Id = "MasterDesktopActionsMenuFavorites", 5018 SortId = 30, 5019 Template = RenderFavorites() 5020 }; 5021 5022 if (!hideMyFavoritesLink && Model.CurrentUser.ID > 0) 5023 { 5024 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuFavorites); 5025 } 5026 } 5027 5028 @helper RenderFavorites() 5029 { 5030 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 5031 string myFavoritesPageLink = "/Default.aspx?ID=" + myFavoritesPageId; 5032 5033 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5034 string liClasses = topLayout != "normal" && topLayout != "splitted-center" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5035 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5036 5037 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5038 <a href="@myFavoritesPageLink" class="@menuLinkClass dw-mod" title="@Translate("Favorites")"> 5039 <i class="fas fa-@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue fa-1_5x"></i> 5040 </a> 5041 </li> 5042 } 5043 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5044 5045 @using System 5046 @using System.Web 5047 @using Dynamicweb.Rapido.Blocks.Extensibility 5048 @using Dynamicweb.Rapido.Blocks 5049 @using Dynamicweb.Rapido.Services 5050 5051 @{ 5052 bool hideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart"); 5053 string miniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown"; 5054 5055 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !hideCart) 5056 { 5057 Block masterDesktopActionsMenuMiniCart = new Block 5058 { 5059 Id = "MasterDesktopActionsMenuMiniCart", 5060 SortId = 60, 5061 Template = RenderMiniCart(miniCartLayout == "dropdown"), 5062 SkipRenderBlocksList = true, 5063 BlocksList = new List<Block>() 5064 }; 5065 5066 Block miniCartCounterScriptTemplate = new Block 5067 { 5068 Id = "MiniCartCounterScriptTemplate", 5069 Template = RenderMiniCartCounterContent() 5070 }; 5071 5072 //dropdown layout is default 5073 RazorEngine.Templating.TemplateWriter layoutTemplate; 5074 RazorEngine.Templating.TemplateWriter miniCartTriggerTemplate; 5075 5076 switch (miniCartLayout) 5077 { 5078 case "dropdown": 5079 layoutTemplate = RenderMiniCartDropdownLayout(); 5080 miniCartTriggerTemplate = RenderMiniCartTriggerLink(); 5081 break; 5082 case "panel": 5083 layoutTemplate = RenderMiniCartPanelLayout(); 5084 miniCartTriggerTemplate = RenderMiniCartTriggerLabel(); 5085 break; 5086 case "modal": 5087 layoutTemplate = RenderMiniCartModalLayout(); 5088 miniCartTriggerTemplate = RenderMiniCartTriggerLabel(); 5089 break; 5090 case "none": 5091 default: 5092 layoutTemplate = RenderMiniCartDropdownLayout(); 5093 miniCartTriggerTemplate = RenderMiniCartTriggerLink(); 5094 break; 5095 } 5096 5097 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block 5098 { 5099 Id = "MiniCartTrigger", 5100 Template = miniCartTriggerTemplate 5101 }); 5102 5103 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 5104 { 5105 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block 5106 { 5107 Id = "MiniCartLayout", 5108 Template = layoutTemplate 5109 }); 5110 } 5111 5112 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuMiniCart); 5113 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate); 5114 } 5115 5116 if (hideCart && Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 5117 { 5118 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block { 5119 Id = "CartInitialization" 5120 }); 5121 } 5122 } 5123 5124 @helper RenderMiniCart(bool hasMouseEnterEvent) 5125 { 5126 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterDesktopActionsMenuMiniCart").OrderBy(item => item.SortId).ToList(); 5127 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5128 string liClasses = topLayout != "normal" ? "menu__item--top-level" : "menu--clean"; 5129 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5130 string mouseEvent = ""; 5131 string id = "MiniCart"; 5132 if (hasMouseEnterEvent) 5133 { 5134 mouseEvent = "onmouseenter=\"Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=" + miniCartFeedPageId + "&feedType=MiniCart')\""; 5135 id = "miniCartTrigger"; 5136 } 5137 <li class="menu__item menu__item--horizontal menu__item--icon @liClasses dw-mod" id="@id" @mouseEvent> 5138 @RenderBlockList(subBlocks) 5139 </li> 5140 } 5141 5142 @helper RenderMiniCartTriggerLabel() 5143 { 5144 int cartPageId = GetPageIdByNavigationTag("CartPage"); 5145 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart"; 5146 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5147 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5148 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5149 5150 <div class="@menuLinkClass dw-mod js-mini-cart-button" onclick="Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart')" title="@Translate("Cart")"> 5151 <div class="u-inline u-position-relative"> 5152 <i class="@cartIcon fa-1_5x"></i> 5153 @RenderMiniCartCounter() 5154 </div> 5155 </div> 5156 } 5157 5158 @helper RenderMiniCartTriggerLink() 5159 { 5160 int cartPageId = GetPageIdByNavigationTag("CartPage"); 5161 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart"; 5162 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5163 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5164 5165 <a href="/Default.aspx?ID=@cartPageId&Purge=True" class="@menuLinkClass menu__item--icon dw-mod js-mini-cart-button" title="@Translate("Cart")"> 5166 <span class="u-inline u-position-relative"> 5167 <i class="@cartIcon fa-1_5x"></i> 5168 @RenderMiniCartCounter() 5169 </span> 5170 </a> 5171 } 5172 5173 @helper RenderMiniCartCounter() 5174 { 5175 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5176 string cartProductsCount = Model.Cart.TotalProductsCount.ToString(); 5177 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5178 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice"); 5179 string cartProductsTotalPrice = showPrice && Model.Cart.TotalPrice != null ? Model.Cart.TotalPrice.Price.Formatted : ""; 5180 cartProductsTotalPrice = counterPosition == "right" ? cartProductsTotalPrice : ""; 5181 5182 if (showPrice && counterPosition == "right") 5183 { 5184 cartProductsCount = Translate("Cart") + " (" + cartProductsCount + ")"; 5185 } 5186 5187 <span class="mini-cart__counter @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod"> 5188 <span class="js-handlebars-root js-mini-cart-counter" id="cartCounter" data-template="MiniCartCounterContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=Counter" data-init-onload="false" data-preloader="false"> 5189 <span class="js-mini-cart-counter-content" data-count="@Model.Cart.TotalProductsCount.ToString()"> 5190 @cartProductsCount @cartProductsTotalPrice 5191 </span> 5192 </span> 5193 </span> 5194 } 5195 5196 @helper RenderMiniCartCounterContent() 5197 { 5198 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice"); 5199 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5200 bool showPriceInMiniCartCounter = Pageview.Device.ToString() != "Mobile" && counterPosition == "right" && showPrice; 5201 5202 <script id="MiniCartCounterContent" type="text/x-template"> 5203 {{#.}} 5204 <span class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}"> 5205 @if (showPriceInMiniCartCounter) 5206 { 5207 @Translate("Cart")<text>({{numberofproducts}}) {{totalprice}}</text> 5208 } 5209 else 5210 { 5211 <text>{{numberofproducts}}</text> 5212 } 5213 </span> 5214 {{/.}} 5215 </script> 5216 } 5217 5218 @helper RenderMiniCartDropdownLayout() 5219 { 5220 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5221 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5222 5223 <div class="mini-cart mini-cart-dropdown js-mini-cart grid__cell dw-mod" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="dropdown" data-cart-page-link="@cartPageLink"> 5224 <div class="mini-cart-dropdown__inner dw-mod"> 5225 <h3 class="u-ta-center dw-mod">@Translate("Shopping cart")</h3> 5226 <div class="mini-cart-dropdown__body u-flex dw-mod"> 5227 <div class="js-handlebars-root u-flex grid--direction-column u-full-width dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div> 5228 </div> 5229 </div> 5230 </div> 5231 } 5232 5233 @helper RenderMiniCartPanelLayout() 5234 { 5235 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5236 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5237 5238 <div class="mini-cart grid__cell dw-mod"> 5239 <input type="checkbox" id="miniCartTrigger" class="panel-trigger" /> 5240 <div class="panel panel--right panel--with-close-btn dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink"> 5241 <label for="miniCartTrigger" class="panel__close-btn" title="@Translate("Close panel")"><i class="fas fa-times"></i></label> 5242 <div class="panel__content u-full-width dw-mod"> 5243 <h3 class="panel__header dw-mod u-margin-bottom u-ta-center">@Translate("Shopping cart")</h3> 5244 <div class="panel__content-body panel__content-body--cart dw-mod"> 5245 <div class="js-handlebars-root u-flex grid--direction-column u-full-height dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div> 5246 </div> 5247 </div> 5248 </div> 5249 </div> 5250 } 5251 5252 @helper RenderMiniCartModalLayout() 5253 { 5254 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5255 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5256 5257 <div class="mini-cart grid__cell dw-mod"> 5258 <input type="checkbox" id="miniCartTrigger" class="modal-trigger" autocomplete="off" /> 5259 <div class="modal-container dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink"> 5260 <label for="miniCartTrigger" class="modal-overlay"></label> 5261 <div class="modal modal--md modal--top-right dw-mod"> 5262 <div class="modal__body u-flex grid--direction-column dw-mod"> 5263 <h3 class="dw-mod u-ta-center">@Translate("Shopping cart")</h3> 5264 <div class="js-handlebars-root u-flex grid--direction-column dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div> 5265 </div> 5266 <label class="modal__close-btn modal__close-btn--clean dw-mod" for="miniCartTrigger" title="@Translate("Close modal")"></label> 5267 </div> 5268 </div> 5269 </div> 5270 } 5271 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5272 5273 @using System 5274 @using System.Web 5275 @using Dynamicweb.Rapido.Blocks.Extensibility 5276 @using Dynamicweb.Rapido.Blocks 5277 5278 @{ 5279 bool showOrderDraftLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOrderDraftIcon"); 5280 5281 Block masterDesktopActionsMenuOrderDraft = new Block 5282 { 5283 Id = "MasterDesktopActionsMenuOrderDraft", 5284 SortId = 40, 5285 Template = RenderOrderDraft() 5286 }; 5287 5288 if (showOrderDraftLink && Model.CurrentUser.ID > 0) 5289 { 5290 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuOrderDraft); 5291 } 5292 } 5293 5294 @helper RenderOrderDraft() 5295 { 5296 int OrderDraftPageId = GetPageIdByNavigationTag("OrderDraft"); 5297 string OrderDraftPageLink = "/Default.aspx?ID=" + OrderDraftPageId; 5298 string draftIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard"; 5299 5300 5301 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5302 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5303 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5304 5305 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5306 <a href="@OrderDraftPageLink" class="@menuLinkClass dw-mod" title="@Translate("My Pending Orders")"> 5307 <span class="u-inline u-position-relative"> 5308 <i class="fa fa-th-list fa-1_5x"></i> 5309 </span> 5310 </a> 5311 </li> 5312 5313 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5314 <a href="Default.aspx?ID=6561" class="@menuLinkClass dw-mod" title="@Translate("Pending to Approve")"> 5315 <span class="u-inline u-position-relative"> 5316 <i class="fa fa-clipboard-list-check fa-1_5x"></i> 5317 </span> 5318 </a> 5319 </li> 5320 } 5321 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5322 5323 @using System 5324 @using System.Web 5325 @using Dynamicweb.Rapido.Blocks.Extensibility 5326 @using Dynamicweb.Rapido.Blocks 5327 5328 @{ 5329 bool showDownloadCartLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart"); 5330 5331 Block masterDesktopActionsMenuDownloadCart = new Block 5332 { 5333 Id = "MasterDesktopActionsMenuDownloadCart", 5334 SortId = 50, 5335 Template = RenderDownloadCart() 5336 }; 5337 5338 if (showDownloadCartLink && Model.CurrentUser.ID > 0) 5339 { 5340 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuDownloadCart); 5341 } 5342 } 5343 5344 @helper RenderDownloadCart() 5345 { 5346 int downloadCartPageId = GetPageIdByNavigationTag("DownloadCart"); 5347 string downloadCartPageLink = "/Default.aspx?ID=" + downloadCartPageId; 5348 5349 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5350 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5351 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5352 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5353 5354 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5355 <a href="@downloadCartPageLink" class="@menuLinkClass dw-mod" title="@Translate("Download cart")"> 5356 <span class="u-inline u-position-relative"> 5357 <i class="fas fa-cart-arrow-down fa-1_5x"></i> 5358 <span class="mini-cart__counter u-hidden @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod js-download-cart-counter"></span> 5359 </span> 5360 </a> 5361 </li> 5362 } 5363 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5364 5365 @using System 5366 @using System.Web 5367 @using Dynamicweb.Rapido.Blocks.Extensibility 5368 @using Dynamicweb.Rapido.Blocks 5369 5370 @functions { 5371 public class SearchConfiguration 5372 { 5373 public string searchFeedId { get; set; } 5374 public string searchSecondFeedId { get; set; } 5375 public int groupsFeedId { get; set; } 5376 public string resultPageLink { get; set; } 5377 public string searchPlaceholder { get; set; } 5378 public string searchType { get; set; } 5379 public string searchTemplate { get; set; } 5380 public string searchContentTemplate { get; set; } 5381 public string searchValue { get; set; } 5382 public bool showGroups { get; set; } 5383 5384 public SearchConfiguration() 5385 { 5386 searchFeedId = ""; 5387 searchSecondFeedId = ""; 5388 searchType = "product-search"; 5389 searchContentTemplate = ""; 5390 showGroups = true; 5391 } 5392 } 5393 } 5394 @{ 5395 Block masterSearchBar = new Block 5396 { 5397 Id = "MasterSearchBar", 5398 SortId = 40, 5399 Template = RenderSearch("bar"), 5400 Design = new Design 5401 { 5402 Size = "auto", 5403 HidePadding = true, 5404 RenderType = RenderType.Column 5405 } 5406 }; 5407 5408 Block masterSearchAction = new Block 5409 { 5410 Id = "MasterDesktopActionsMenuSearch", 5411 SortId = 10, 5412 Template = RenderSearch() 5413 }; 5414 5415 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterSearchBar); 5416 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterSearchAction); 5417 } 5418 5419 @helper RenderSearch(string type = "mini-search") 5420 { 5421 string productsPageId = Converter.ToString(GetPageIdByNavigationTag("ProductsPage")); 5422 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 5423 string searchType = Model.Area.Item.GetItem("Layout").GetList("TopSearch") != null ? Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue : "productSearch"; 5424 5425 SearchConfiguration searchConfiguration = null; 5426 5427 switch (searchType) { 5428 case "contentSearch": 5429 searchConfiguration = new SearchConfiguration() { 5430 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true", 5431 resultPageLink = contentSearchPageLink, 5432 searchPlaceholder = Translate("Search page"), 5433 groupsFeedId = 0, 5434 searchType = "content-search", 5435 searchTemplate = "SearchPagesTemplate", 5436 showGroups = false 5437 }; 5438 break; 5439 case "combinedSearch": 5440 searchConfiguration = new SearchConfiguration() { 5441 searchFeedId = productsPageId + "&feed=true", 5442 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true", 5443 resultPageLink = Converter.ToString(productsPageId), 5444 searchPlaceholder = Translate("Search products or pages"), 5445 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"), 5446 searchType = "combined-search", 5447 searchTemplate = "SearchProductsTemplateWrap", 5448 searchContentTemplate = "SearchPagesTemplateWrap", 5449 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector") 5450 }; 5451 break; 5452 default: //productSearch 5453 searchConfiguration = new SearchConfiguration() { 5454 resultPageLink = Converter.ToString(productsPageId), 5455 searchFeedId = productsPageId + "&feed=true", 5456 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"), 5457 searchPlaceholder = Translate("Search products"), 5458 searchTemplate = "SearchProductsTemplate", 5459 searchType = "product-search", 5460 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector") 5461 }; 5462 break; 5463 } 5464 searchConfiguration.searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 5465 5466 if (type == "mini-search") { 5467 @RenderMiniSearch(searchConfiguration) 5468 } else { 5469 @RenderSearchBar(searchConfiguration) 5470 } 5471 } 5472 5473 @helper RenderSearchBar(SearchConfiguration options) 5474 { 5475 <div class="typeahead typeahead--centered u-color-inherit js-typeahead dw-mod" id="ProductSearchBar" 5476 data-page-size="7" 5477 data-search-feed-id="@options.searchFeedId" 5478 data-search-second-feed-id="@options.searchSecondFeedId" 5479 data-result-page-id="@options.resultPageLink" 5480 data-groups-page-id="@options.groupsFeedId" 5481 data-search-type="@options.searchType"> 5482 @if (options.showGroups) 5483 { 5484 <button type="button" class="btn btn--condensed u-color-light-gray--bg typeahead-group-btn dw-mod js-typeahead-groups-btn" data-group-id="all">@Translate("All")</button> 5485 <ul class="dropdown dropdown--absolute-position u-min-w220px js-handlebars-root js-typeahead-groups-content dw-mod" id="ProductSearchBarGroupsContent" data-template="SearchGroupsTemplate" data-json-feed="/Default.aspx?ID=@options.groupsFeedId&feedType=productGroups" data-init-onload="false" data-preloader="minimal"></ul> 5486 } 5487 <div class="typeahead-search-field"> 5488 <input type="text" class="u-no-margin u-full-width u-full-height js-typeahead-search-field" placeholder="@options.searchPlaceholder" value="@options.searchValue"> 5489 @if (string.IsNullOrEmpty(options.searchSecondFeedId)) 5490 { 5491 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly" data-init-onload="false"></ul> 5492 } 5493 else 5494 { 5495 <div class="dropdown dropdown--absolute-position dropdown--combined grid"> 5496 <div class="js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-init-onload="false"></div> 5497 <div class="js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="ContentSearchBarContent" data-template="@options.searchContentTemplate" data-init-onload="false"></div> 5498 </div> 5499 } 5500 </div> 5501 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn" title="@Translate("Search")"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue"></i></button> 5502 </div> 5503 } 5504 5505 @helper RenderMiniSearch(SearchConfiguration options) 5506 { 5507 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5508 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5509 5510 <li class="menu__item menu__item--horizontal menu__item--top-level menu__item--icon u-hidden-xxs is-dropdown is-dropdown--no-icon dw-mod" id="miniSearchIcon"> 5511 <div class="@menuLinkClass dw-mod" title="@Translate("Search")"> 5512 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i> 5513 </div> 5514 <div class="menu menu--dropdown menu--dropdown-right u-no-padding u-w380px grid__cell dw-mod"> 5515 <div class="typeahead js-typeahead" id="ProductSearchBar" 5516 data-page-size="7" 5517 data-search-feed-id="@options.searchFeedId" 5518 data-search-second-feed-id="@options.searchSecondFeedId" 5519 data-result-page-id="@options.resultPageLink" 5520 data-search-type="@options.searchType"> 5521 <div class="typeahead-search-field"> 5522 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" id="headerSearch" placeholder="@options.searchPlaceholder" value="@options.searchValue"> 5523 @if (string.IsNullOrEmpty(options.searchSecondFeedId)) 5524 { 5525 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly" data-init-onload="false"></ul> 5526 } 5527 else 5528 { 5529 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--right-aligned"> 5530 <div class="js-handlebars-root js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly" data-init-onload="false"></div> 5531 <div class="js-handlebars-root js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="ContentSearchBarContent" data-template="@options.searchContentTemplate" data-json-feed="/Default.aspx?ID=@options.searchSecondFeedId" data-init-onload="false"></div> 5532 </div> 5533 } 5534 </div> 5535 </div> 5536 </div> 5537 </li> 5538 } 5539 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5540 5541 @using System 5542 @using System.Web 5543 @using Dynamicweb.Rapido.Blocks.Extensibility 5544 @using Dynamicweb.Rapido.Blocks 5545 5546 @{ 5547 string headerConfigurationTopLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5548 bool headerConfigurationHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 5549 5550 BlocksPage headerConfigurationPage = BlocksPage.GetBlockPage("Master"); 5551 5552 Block configDesktopLogo = headerConfigurationPage.GetBlockById("MasterDesktopLogo"); 5553 headerConfigurationPage.RemoveBlock(configDesktopLogo); 5554 5555 Block configDesktopMenu = headerConfigurationPage.GetBlockById("MasterDesktopMenu"); 5556 headerConfigurationPage.RemoveBlock(configDesktopMenu); 5557 5558 Block configSearchBar = headerConfigurationPage.GetBlockById("MasterSearchBar"); 5559 headerConfigurationPage.RemoveBlock(configSearchBar); 5560 5561 Block configSearchAction = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenuSearch"); 5562 headerConfigurationPage.RemoveBlock(configSearchAction); 5563 5564 Block configDesktopActionsMenu = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenu"); 5565 headerConfigurationPage.RemoveBlock(configDesktopActionsMenu); 5566 5567 Block configDesktopExtra = headerConfigurationPage.GetBlockById("MasterDesktopExtra"); 5568 5569 switch (headerConfigurationTopLayout) 5570 { 5571 case "condensed": //2 5572 configDesktopLogo.Design.Size = "auto-width"; 5573 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5574 5575 configDesktopMenu.SortId = 20; 5576 configDesktopMenu.Design.Size = "auto"; 5577 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5578 5579 configDesktopActionsMenu.SortId = 30; 5580 configDesktopActionsMenu.Design.Size = "auto-width"; 5581 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5582 5583 if (!headerConfigurationHideSearch) 5584 { 5585 configSearchBar.SortId = 40; 5586 configSearchBar.Design.Size = "12"; 5587 configDesktopExtra.SortId = 50; 5588 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 5589 } 5590 break; 5591 case "splitted": //3 5592 configDesktopLogo.Design.Size = "auto"; 5593 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5594 5595 if (!headerConfigurationHideSearch) 5596 { 5597 configSearchBar.SortId = 20; 5598 configSearchBar.Design.Size = "auto"; 5599 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 5600 } 5601 5602 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5603 5604 configDesktopActionsMenu.SortId = 20; 5605 configDesktopActionsMenu.Design.Size = "auto-width"; 5606 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5607 break; 5608 case "splitted-center": //4 5609 configDesktopLogo.Design.Size = "auto"; 5610 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5611 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5612 5613 configDesktopActionsMenu.SortId = 30; 5614 configDesktopActionsMenu.Design.Size = "auto-width"; 5615 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu); 5616 5617 if (!headerConfigurationHideSearch) 5618 { 5619 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5620 } 5621 break; 5622 case "minimal": //5 5623 configDesktopLogo.Design.Size = "auto-width"; 5624 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5625 5626 configDesktopMenu.Design.Size = "auto"; 5627 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5628 5629 configDesktopActionsMenu.SortId = 20; 5630 configDesktopActionsMenu.Design.Size = "auto-width"; 5631 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5632 5633 if (!headerConfigurationHideSearch) 5634 { 5635 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5636 } 5637 break; 5638 case "minimal-center": //6 5639 configDesktopLogo.Design.Size = "auto-width"; 5640 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5641 5642 configDesktopMenu.Design.Size = "auto"; 5643 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5644 5645 configDesktopActionsMenu.SortId = 20; 5646 configDesktopActionsMenu.Design.Size = "auto-width"; 5647 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5648 5649 if (!headerConfigurationHideSearch) 5650 { 5651 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5652 } 5653 break; 5654 case "minimal-right": //7 5655 configDesktopLogo.Design.Size = "auto-width"; 5656 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5657 5658 configDesktopMenu.Design.Size = "auto"; 5659 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5660 5661 configDesktopActionsMenu.SortId = 20; 5662 configDesktopActionsMenu.Design.Size = "auto-width"; 5663 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5664 5665 if (!headerConfigurationHideSearch) 5666 { 5667 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5668 } 5669 break; 5670 case "two-lines": //8 5671 configDesktopLogo.Design.Size = "auto"; 5672 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5673 5674 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5675 5676 configDesktopActionsMenu.SortId = 20; 5677 configDesktopActionsMenu.Design.Size = "auto-width"; 5678 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5679 5680 if (!headerConfigurationHideSearch) 5681 { 5682 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5683 } 5684 break; 5685 case "two-lines-centered": //9 5686 configDesktopLogo.Design.Size = "auto"; 5687 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5688 5689 configDesktopMenu.Design.Size = "auto-width"; 5690 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5691 5692 configDesktopActionsMenu.SortId = 20; 5693 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5694 5695 if (!headerConfigurationHideSearch) 5696 { 5697 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5698 } 5699 break; 5700 case "normal": //1 5701 default: 5702 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5703 5704 if (!headerConfigurationHideSearch) 5705 { 5706 configSearchBar.SortId = 20; 5707 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 5708 } 5709 5710 configDesktopActionsMenu.SortId = 30; 5711 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu); 5712 5713 configDesktopActionsMenu.Design.Size = "auto-width"; 5714 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5715 break; 5716 } 5717 } 5718 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5719 5720 @using System 5721 @using System.Web 5722 @using Dynamicweb.Rapido.Blocks.Extensibility 5723 @using Dynamicweb.Rapido.Blocks 5724 5725 @{ 5726 5727 } 5728 5729 5730 @helper RenderDesktopTools() 5731 { 5732 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopTools").OrderBy(item => item.SortId).ToList(); 5733 5734 <div class="tools-navigation dw-mod"> 5735 <div class="center-container grid top-container__center-container dw-mod"> 5736 @RenderBlockList(subBlocks) 5737 5738 </div> 5739 </div> 5740 } 5741 5742 @helper RenderDesktopToolsText() 5743 { 5744 string toolsText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("ToolsText"); 5745 if (!string.IsNullOrEmpty(toolsText)) 5746 { 5747 <div class="u-margin-top u-margin-bottom">@toolsText</div> 5748 } 5749 } 5750 5751 @helper RenderDesktopToolsNavigation() 5752 { 5753 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 5754 5755 if (renderPagesInToolBar) 5756 { 5757 @RenderNavigation(new 5758 { 5759 id = "topToolsNavigation", 5760 cssclass = "menu menu-tools dw-mod dwnavigation", 5761 template = "TopMenu.xslt" 5762 }) 5763 } 5764 } 5765 5766 @helper RenderDesktopNavigation() 5767 { 5768 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopNavigation").OrderBy(item => item.SortId).ToList(); 5769 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5770 string alignClass = topLayout == "two-lines-centered" ? "grid--justify-center" : ""; 5771 <nav class="main-navigation dw-mod"> 5772 <div class="center-container top-container__center-container grid @alignClass dw-mod"> 5773 @RenderBlockList(subBlocks) 5774 5775 </div> 5776 </nav> 5777 } 5778 5779 @helper RenderDesktopExtra() 5780 { 5781 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopExtra").OrderBy(item => item.SortId).ToList(); 5782 5783 if (subBlocks.Count > 0) 5784 { 5785 <div class="header header-top dw-mod"> 5786 <div class="center-container top-container__center-container grid--justify-space-between grid grid--align-center dw-mod"> 5787 @RenderBlockList(subBlocks) 5788 </div> 5789 </div> 5790 } 5791 }</text> 5792 } 5793 5794 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5795 5796 @using System 5797 @using System.Web 5798 @using Dynamicweb.Rapido.Blocks.Extensibility 5799 @using Dynamicweb.Rapido.Blocks 5800 @using Dynamicweb.Rapido.Blocks.Components.General 5801 @using Dynamicweb.Frontend 5802 5803 @functions { 5804 int impersonationPageId; 5805 string impersonationLayout; 5806 int impersonationFeed; 5807 Block impersonationBar; 5808 5809 string getUserNameFromParams(string firstName, string middleName, string lastName, string name, string email, string userName) 5810 { 5811 string username = ""; 5812 5813 if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName)) 5814 { 5815 username = firstName + " " + (!string.IsNullOrEmpty(middleName) ? middleName + " " : "") + lastName; 5816 } 5817 else if (!string.IsNullOrEmpty(name)) 5818 { 5819 username = name; 5820 } 5821 else if (!string.IsNullOrEmpty(email)) 5822 { 5823 username = email; 5824 } 5825 else 5826 { 5827 username = userName; 5828 } 5829 return username; 5830 } 5831 5832 string getUserName(UserViewModel user) 5833 { 5834 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName); 5835 } 5836 5837 string getUserName(Dynamicweb.Security.UserManagement.User user) 5838 { 5839 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName); 5840 } 5841 } 5842 5843 @{ 5844 impersonationPageId = GetPageIdByNavigationTag("Impersonation"); 5845 impersonationLayout = Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout") != null ? Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout").SelectedValue : "bar"; 5846 impersonationFeed = GetPageIdByNavigationTag("UsersFeed"); 5847 5848 if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0) 5849 { 5850 impersonationBar = new Block 5851 { 5852 Id = "ImpersonationBar", 5853 SortId = 50, 5854 Template = RenderImpersonation(), 5855 SkipRenderBlocksList = true, 5856 Design = new Design 5857 { 5858 Size = "auto-width", 5859 HidePadding = true, 5860 RenderType = RenderType.Column 5861 } 5862 }; 5863 5864 if (impersonationLayout == "top-bar") { 5865 impersonationBar.SortId = 9; 5866 } 5867 5868 Block impersonationContent = new Block 5869 { 5870 Id = "ImpersonationContent", 5871 SortId = 20 5872 }; 5873 5874 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0) 5875 { 5876 //Render stop impersonation view 5877 impersonationContent.Template = RenderStopImpersonationView(); 5878 5879 5880 Modal stopImpersonation = new Modal 5881 { 5882 Id = "StopImpersonation", 5883 Heading = new Heading { 5884 Level = 2, 5885 Title = Translate("Sign out"), 5886 Icon = new Icon { 5887 Name = "fa-sign-out", 5888 Prefix = "fas", 5889 LabelPosition = IconLabelPosition.After 5890 } 5891 }, 5892 Width = ModalWidth.Sm, 5893 BodyTemplate = RenderStopImpersonationForm() 5894 }; 5895 5896 Block stopImpersonationBlock = new Block 5897 { 5898 Id = "StopImpersonationBlock", 5899 SortId = 10, 5900 Component = stopImpersonation 5901 }; 5902 impersonationBar.BlocksList.Add(stopImpersonationBlock); 5903 } 5904 else 5905 { 5906 //Render main view 5907 switch (impersonationLayout) 5908 { 5909 case "right-lower-box": 5910 impersonationContent.BlocksList.Add( 5911 new Block { 5912 Id = "RightLowerBoxHeader", 5913 SortId = 10, 5914 Component = new Heading { 5915 Level = 5, 5916 Title = Translate("View the list of users you can sign in as"), 5917 CssClass = "impersonation-text" 5918 } 5919 } 5920 ); 5921 impersonationContent.BlocksList.Add( 5922 new Block { 5923 Id = "RightLowerBoxContent", 5924 SortId = 20, 5925 Template = RenderImpersonationControls() 5926 } 5927 ); 5928 break; 5929 case "right-lower-bar": 5930 impersonationContent.BlocksList.Add( 5931 new Block { 5932 Id = "RightLowerBarContent", 5933 SortId = 10, 5934 Template = RenderImpersonationControls() 5935 } 5936 ); 5937 break; 5938 case "bar": 5939 default: 5940 impersonationContent.BlocksList.Add( 5941 new Block { 5942 Id = "ViewListLink", 5943 SortId = 20, 5944 Template = RenderViewListLink() 5945 } 5946 ); 5947 impersonationContent.BlocksList.Add( 5948 new Block { 5949 Id = "BarTypeaheadSearch", 5950 SortId = 30, 5951 Template = RenderTypeaheadSearch() 5952 } 5953 ); 5954 break; 5955 } 5956 } 5957 impersonationBar.BlocksList.Add(impersonationContent); 5958 5959 impersonationBar.BlocksList.Add( 5960 new Block 5961 { 5962 Id = "ImpersonationSearchTemplates", 5963 SortId = 30, 5964 Template = RenderSearchResultTemplate() 5965 } 5966 ); 5967 if (impersonationLayout != "bar" && impersonationLayout != "top-bar") 5968 { 5969 impersonationBar.BlocksList.Add( 5970 new Block 5971 { 5972 Id = "ImpersonationSearchScripts", 5973 SortId = 40, 5974 Template = RenderSearchScripts() 5975 } 5976 ); 5977 } 5978 BlocksPage.GetBlockPage("Master").Add("MasterHeader", impersonationBar); 5979 } 5980 } 5981 5982 @helper RenderImpersonation() 5983 { 5984 List<Block> subBlocks = impersonationBar.BlocksList.OrderBy(item => item.SortId).ToList(); 5985 <input type="checkbox" class="impersonation-trigger js-remember-state" id="ImpersonationMinimizeTrigger" /> 5986 <div class="impersonation impersonation--@(impersonationLayout)-layout dw-mod" id="Impersonation"> 5987 @if (impersonationLayout == "right-lower-box") 5988 { 5989 @RenderRightLowerBoxHeader() 5990 } 5991 <div class="center-container top-container__center-container impersonation__container @(impersonationLayout != "bar" && impersonationLayout != "top-bar" ? "impersonation__container--box" : "") dw-mod"> 5992 @*Impersonation*@ 5993 @RenderBlockList(subBlocks) 5994 </div> 5995 </div> 5996 } 5997 5998 @helper RenderRightLowerBoxHeader() 5999 { 6000 <div class="impersonation__header dw-mod"> 6001 <div class="impersonation__title">@Translate("Impersonation")</div> 6002 <label for="ImpersonationMinimizeTrigger" class="btn btn--impersonation impersonation__minimize-btn dw-mod" onclick="this.blur();"> 6003 @Render(new Icon 6004 { 6005 Prefix = "fas", 6006 Name = "fa-window-minimize" 6007 }) 6008 </label> 6009 </div> 6010 } 6011 6012 @helper RenderStopImpersonationView() 6013 { 6014 string secondaryUserName = getUserName(Model.CurrentSecondaryUser); 6015 string userName = getUserName(Pageview.User); 6016 string impersonationText = "<span class=\"impersonation-light-text dw-mod\">" + Translate("Logged in as") + "</span> <b>" + secondaryUserName + "</b> <span class=\"impersonation-light-text dw-mod\">" + Translate("by") + "</span> <b>" + userName + "</b> "; 6017 impersonationText = Dynamicweb.Security.UserManagement.User.ImpersonationMode == Dynamicweb.Security.UserManagement.UserImpersonation.Full ? "<span class=\"impersonation-light-text dw-mod\">" + Translate("Logged in as") + "</span> <b>" + userName + "</b> <span class=\"impersonation-light-text dw-mod\">" + Translate("by") + "</span> <b>" + secondaryUserName + "</b> " : impersonationText; 6018 6019 if (impersonationLayout == "right-lower-box") 6020 { 6021 <div class="u-margin-bottom--lg u-ta-center"> 6022 @impersonationText 6023 </div> 6024 <div class="u-margin-bottom--lg u-ta-center"> 6025 @RenderSwitchAccountButton() 6026 </div> 6027 @RenderStopImpersonationButton() 6028 } 6029 else 6030 { 6031 <div class="grid grid--align-center impersonation__stop-wrap"> 6032 <div class="impersonation-bar-item dw-mod"> 6033 @impersonationText 6034 </div> 6035 <div class="impersonation-bar-item dw-mod"> 6036 @RenderSwitchAccountButton() 6037 </div> 6038 <div class="impersonation-bar-item dw-mod"> 6039 @RenderStopImpersonationButton() 6040 </div> 6041 </div> 6042 } 6043 } 6044 6045 @helper RenderSwitchAccountButton() { 6046 @Render(new Button 6047 { 6048 Href = "/Default.aspx?ID=" + impersonationPageId, 6049 ButtonType = ButtonType.Button, 6050 ButtonLayout = ButtonLayout.Clean, 6051 Title = Translate("Switch account"), 6052 Icon = new Icon { 6053 Name = "fa-users", 6054 Prefix = "fal", 6055 LabelPosition = IconLabelPosition.After 6056 }, 6057 CssClass = "u-no-margin u-color-inherit" 6058 }) 6059 } 6060 6061 @helper RenderStopImpersonationForm() 6062 { 6063 string secondaryUserName = getUserName(Model.CurrentSecondaryUser); 6064 string userName = getUserName(Pageview.User); 6065 int pageId = Model.TopPage.ID; 6066 6067 <form method="post" class="u-no-margin"> 6068 @Render(new Button 6069 { 6070 ButtonType = ButtonType.Submit, 6071 ButtonLayout = ButtonLayout.Secondary, 6072 Title = Translate("Sign out as") + " " + userName, 6073 Href = "/Default.aspx?ID=" + impersonationPageId, 6074 CssClass = "btn--full", 6075 Name = "DwExtranetRemoveSecondaryUser" 6076 }) 6077 6078 @Render(new Button 6079 { 6080 ButtonType = ButtonType.Submit, 6081 ButtonLayout = ButtonLayout.Secondary, 6082 Title = Translate("Sign out as") + " " + secondaryUserName, 6083 Href = "/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, 6084 CssClass = "btn--full", 6085 Name = "DwExtranetRemoveSecondaryUser" 6086 }) 6087 </form> 6088 } 6089 6090 @helper RenderStopImpersonationButton() { 6091 @Render(new Button 6092 { 6093 ButtonType = ButtonType.Button, 6094 ButtonLayout = ButtonLayout.Clean, 6095 Title = Translate("Sign out"), 6096 Icon = new Icon { 6097 Name = "fa-sign-out", 6098 Prefix = "fal", 6099 LabelPosition = IconLabelPosition.After 6100 }, 6101 OnClick = "document.getElementById('StopImpersonationModalTrigger').checked = true", 6102 CssClass = "u-no-margin" 6103 }) 6104 } 6105 6106 @helper RenderImpersonationControls() 6107 { 6108 <div class="impersonation__controls"> 6109 @RenderViewListLink() 6110 @RenderSearchBox() 6111 </div> 6112 @RenderResultsList() 6113 } 6114 6115 @helper RenderViewListLink() 6116 { 6117 string title = impersonationLayout == "right-lower-box" ? Translate("View the list") : Translate("View the list of users you can sign in as"); 6118 string buttonClasses = impersonationLayout == "right-lower-box" ? "impersonation__button btn btn--impersonation" : "impersonation__link impersonation__link"; 6119 6120 @Render(new Link { 6121 ButtonLayout = ButtonLayout.None, 6122 Title = title, 6123 Href = "/Default.aspx?ID=" + impersonationPageId, 6124 CssClass = buttonClasses 6125 }) 6126 } 6127 6128 @helper RenderSearchBox() 6129 { 6130 <div class="impersonation__search-wrap"> 6131 <input placeholder="@Translate("Search users")" type="text" class="impersonation__search-field dw-mod" onkeyup="searchKeyUpHandler(event)" id="ImpersonationBoxSearchField"> 6132 <div id="ImpersonationBoxSearchFind" class="impersonation__search-icon dw-mod" onclick="updateResults(document.getElementById('ImpersonationBoxSearchField').value)"> 6133 <i class="fal fa-search"></i> 6134 </div> 6135 <div id="ImpersonationBoxSearchClear" class="impersonation__search-icon u-hidden dw-mod" onclick="clearResults();"> 6136 <i class="fal fa-times"></i> 6137 </div> 6138 </div> 6139 } 6140 6141 @helper RenderTypeaheadSearch() 6142 { 6143 <div class="typeahead u-ta-right impersonation__typeahead js-typeahead dw-mod" id="ImpersonationSearchBar" 6144 data-page-size="5" 6145 data-search-feed-id="@impersonationFeed" 6146 data-result-page-id="@impersonationPageId" 6147 data-search-type="user-search" 6148 data-search-parameter-name="q"> 6149 6150 <div class="typeahead-search-field"> 6151 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" placeholder="@Translate("Search users")"> 6152 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ImpersonationSearchBarContent" data-template="ImpersonationSearchResult" data-json-feed="/Default.aspx?ID=@impersonationFeed" data-init-onload="false"></ul> 6153 </div> 6154 </div> 6155 } 6156 6157 @helper RenderResultsList() 6158 { 6159 <ul id="ImpersonationBoxSearchResults" class="impersonation__search-results js-handlebars-root dw-mod" data-template="ImpersonationSearchResult" data-json-feed="/Default.aspx?ID=@impersonationFeed" data-init-onload="false" data-preloader="minimal"></ul> 6160 } 6161 6162 @helper RenderSearchResultTemplate() 6163 { 6164 <script id="ImpersonationSearchResult" type="text/x-template"> 6165 {{#.}} 6166 {{#Users}} 6167 <li class="impersonation__search-results-item impersonation-user"> 6168 <form method="post" class="impersonation-user__form" name="account{{id}}"> 6169 <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" value="{{id}}"> 6170 <div class="impersonation-user__info"> 6171 <div class="impersonation-user__name">{{userName}}</div> 6172 <div class="impersonation-user__number">{{customerNumber}}</div> 6173 </div> 6174 @Render(new Button 6175 { 6176 ButtonType = ButtonType.Submit, 6177 ButtonLayout = ButtonLayout.Secondary, 6178 Title = Translate("Sign in as"), 6179 CssClass = "impersonation-user__sign-in-btn" + (impersonationLayout != "bar" ? " btn--impersonation" : "") 6180 }) 6181 </form> 6182 </li> 6183 {{/Users}} 6184 {{#unless Users}} 6185 <li class="impersonation__search-results-item impersonation__search-results-item--not-found"> 6186 @Translate("Your search gave 0 results") 6187 </li> 6188 {{/unless}} 6189 {{/.}} 6190 </script> 6191 } 6192 6193 @helper RenderSearchScripts() 6194 { 6195 <script> 6196 let inputDelayTimer; 6197 function searchKeyUpHandler(e) { 6198 clearTimeout(inputDelayTimer); 6199 let value = e.target.value; 6200 if (value != "") { 6201 inputDelayTimer = setTimeout(function () { 6202 updateResults(value); 6203 }, 500); 6204 } else { 6205 clearResults(); 6206 } 6207 }; 6208 6209 function updateResults(value) { 6210 if (value == "") { 6211 return null; 6212 } 6213 HandlebarsBolt.UpdateContent("ImpersonationBoxSearchResults", "/Default.aspx?ID=@impersonationFeed&q=" + value); 6214 document.getElementById("ImpersonationBoxSearchFind").classList.add("u-hidden"); 6215 document.getElementById("ImpersonationBoxSearchClear").classList.remove("u-hidden"); 6216 } 6217 6218 function clearResults() { 6219 document.getElementById("ImpersonationBoxSearchField").value = ""; 6220 HandlebarsBolt.CleanContainer("ImpersonationBoxSearchResults"); 6221 document.getElementById("ImpersonationBoxSearchFind").classList.remove("u-hidden"); 6222 document.getElementById("ImpersonationBoxSearchClear").classList.add("u-hidden"); 6223 } 6224 </script> 6225 } 6226 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6227 6228 @using System 6229 @using System.Web 6230 @using System.Collections.Generic 6231 @using Dynamicweb.Rapido.Blocks.Extensibility 6232 @using Dynamicweb.Rapido.Blocks 6233 6234 @{ 6235 BlocksPage miniCartBlocksPage = BlocksPage.GetBlockPage("Master"); 6236 string orderlinesView = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView").SelectedValue : "table"; 6237 6238 Block orderLines = new Block 6239 { 6240 Id = "MiniCartOrderLines", 6241 SkipRenderBlocksList = true, 6242 BlocksList = new List<Block> 6243 { 6244 new Block { 6245 Id = "MiniCartOrderLinesList", 6246 SortId = 20, 6247 Template = RenderMiniCartOrderLinesList() 6248 } 6249 } 6250 }; 6251 6252 Block orderlinesScriptTemplates = new Block 6253 { 6254 Id = "OrderlinesScriptTemplates" 6255 }; 6256 6257 if (orderlinesView == "table") 6258 { 6259 orderLines.Template = RenderMiniCartOrderLinesTable(); 6260 orderLines.BlocksList.Add( 6261 new Block 6262 { 6263 Id = "MiniCartOrderlinesTableHeader", 6264 SortId = 10, 6265 Template = RenderMiniCartOrderLinesHeader() 6266 } 6267 ); 6268 6269 orderlinesScriptTemplates.Template = RenderMiniCartScriptsTableTemplates(); 6270 } 6271 else 6272 { 6273 orderLines.Template = RenderMiniCartOrderLinesBlocks(); 6274 orderlinesScriptTemplates.Template = RenderMiniCartScriptsListTemplates(); 6275 } 6276 6277 miniCartBlocksPage.Add("MasterBottomSnippets", orderlinesScriptTemplates); 6278 6279 6280 Block miniCartScriptTemplates = new Block() 6281 { 6282 Id = "MasterMiniCartTemplates", 6283 SortId = 1, 6284 Template = RenderMiniCartScriptTemplates(), 6285 SkipRenderBlocksList = true, 6286 BlocksList = new List<Block> 6287 { 6288 orderLines, 6289 new Block { 6290 Id = "MiniCartFooter", 6291 Template = RenderMiniCartFooter(), 6292 SortId = 50, 6293 SkipRenderBlocksList = true, 6294 BlocksList = new List<Block> 6295 { 6296 new Block { 6297 Id = "MiniCartSubTotal", 6298 Template = RenderMiniCartSubTotal(), 6299 SortId = 30 6300 }, 6301 new Block { 6302 Id = "MiniCartFees", 6303 Template = RenderMiniCartFees(), 6304 SortId = 40 6305 }, 6306 new Block { 6307 Id = "MiniCartPoints", 6308 Template = RenderMiniCartPoints(), 6309 SortId = 50 6310 }, 6311 new Block { 6312 Id = "MiniCartTotal", 6313 Template = RenderMiniCartTotal(), 6314 SortId = 60 6315 }, 6316 new Block { 6317 Id = "MiniCartDisclaimer", 6318 Template = RenderMiniCartDisclaimer(), 6319 SortId = 70 6320 }, 6321 new Block { 6322 Id = "MiniCartActions", 6323 Template = RenderMiniCartActions(), 6324 SortId = 80 6325 } 6326 } 6327 } 6328 } 6329 }; 6330 6331 miniCartBlocksPage.Add("MasterBottomSnippets", miniCartScriptTemplates); 6332 } 6333 6334 @helper RenderMiniCartScriptsTableTemplates() 6335 { 6336 6337 <script id="MiniCartOrderline" type="text/x-template"> 6338 {{#unless isEmpty}} 6339 <tr> 6340 <td class="u-w60px"><a href="{{link}}" class="{{hideimage}}"><img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=50&height=50&crop=5&Compression=75&image={{image}}" alt="{{name}}" title="{{name}}"></a></td> 6341 <td class="u-va-middle"> 6342 <a href="{{link}}" class="mini-cart-orderline__name" title="{{name}}">{{name}}</a> 6343 {{#if variantname}} 6344 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{variantname}}</a> 6345 {{/if}} 6346 {{#if unitname}} 6347 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{unitname}}</div> 6348 {{/if}} 6349 </td> 6350 <td class="u-ta-right u-va-middle">{{quantity}}</td> 6351 {{#ifCond isEndUser "===" false}} 6352 <td class="u-ta-right u-va-middle"> 6353 {{#if pointsTotal}} 6354 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 6355 {{else}} 6356 {{#ifCond pricedouble '>' 0}} 6357 {{totalprice}} 6358 {{else}} 6359 {{#ifCond showPrice '===' true}} 6360 {{totalprice}} 6361 {{else}} 6362 <span>-</span> 6363 {{/ifCond}} 6364 {{/ifCond}} 6365 {{/if}} 6366 </td> 6367 {{/ifCond}} 6368 </tr> 6369 {{/unless}} 6370 </script> 6371 6372 <script id="MiniCartOrderlineDiscount" type="text/x-template"> 6373 {{#unless isEmpty}} 6374 <tr class="table__row--no-border"> 6375 <td class="u-w60px">&nbsp;</td> 6376 <td><div class="mini-cart-orderline__name dw-mod">{{name}}</div></td> 6377 <td class="u-ta-right">&nbsp;</td> 6378 {{#ifCond isEndUser "===" false}} 6379 {{#ifCond pricedouble '>' 0 }} 6380 <td class="u-ta-right">{{totalprice}}</td> 6381 {{else}} 6382 <td class="u-w60px">&nbsp;</td> 6383 {{/ifCond}} 6384 {{/ifCond}} 6385 </tr> 6386 {{/unless}} 6387 </script> 6388 } 6389 6390 @helper RenderMiniCartScriptsListTemplates() 6391 { 6392 int cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 6393 6394 <script id="MiniCartOrderline" type="text/x-template"> 6395 {{#unless isEmpty}} 6396 <div class="mini-cart-orderline grid dw-mod"> 6397 <div class="grid__col-4"> 6398 <a href="{{link}}" class="{{hideimage}}"> 6399 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=100&height=100&crop=5&Compression=75&image={{image}}" alt="{{name}}" title="{{name}}"> 6400 </a> 6401 </div> 6402 <div class="grid__col-8"> 6403 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--truncate mini-cart-orderline__name--md u-padding-right--lg" title="{{name}}">{{name}}</a> 6404 {{#if variantname}} 6405 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Variant"): {{variantname}}</div> 6406 {{/if}} 6407 {{#if unitname}} 6408 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Unit"): {{unitname}}</div> 6409 {{/if}} 6410 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Qty"): {{quantity}}</div> 6411 6412 <div class="grid__cell-footer"> 6413 <div class="grid__cell"> 6414 <div class="u-pull--left mini-cart-orderline__price dw-mod"> 6415 {{#if pointsTotal}} 6416 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 6417 {{else}} 6418 {{totalprice}} 6419 {{/if}} 6420 </div> 6421 <button type="button" 6422 title="@Translate("Remove orderline")" 6423 class="btn btn--clean btn--condensed u-pull--right mini-cart-orderline__remove-btn dw-mod" 6424 onclick="{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}}Cart.UpdateCart('miniCartContent', '/Default.aspx?ID=@cartFeedPageId', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);"> 6425 @Translate("Remove") 6426 </button> 6427 </div> 6428 </div> 6429 </div> 6430 </div> 6431 {{/unless}} 6432 </script> 6433 6434 <script id="MiniCartOrderlineDiscount" type="text/x-template"> 6435 {{#unless isEmpty}} 6436 <div class="mini-cart-orderline mini-cart-orderline--discount grid dw-mod"> 6437 <div class="grid__col-4"> 6438 <div class="mini-cart-orderline__name mini-cart-orderline__name dw-mod">{{name}}</div> 6439 </div> 6440 <div class="grid__col-8">{{totalprice}}</div> 6441 </div> 6442 {{/unless}} 6443 </script> 6444 } 6445 6446 @helper RenderMiniCartScriptTemplates() 6447 { 6448 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMiniCartTemplates").OrderBy(item => item.SortId).ToList(); 6449 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 6450 string cartPageLink = string.Concat("/Default.aspx?ID=", GetPageIdByNavigationTag("CartPage")); 6451 bool miniCartUseGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 6452 6453 <script id="MiniCartContent" type="text/x-template"> 6454 {{#.}} 6455 {{#unless isEmpty}} 6456 @if (miniCartUseGoogleTagManager) 6457 { 6458 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 6459 } 6460 @RenderBlockList(subBlocks) 6461 {{/unless}} 6462 {{/.}} 6463 </script> 6464 } 6465 6466 @helper RenderMiniCartOrderLinesTable() 6467 { 6468 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList(); 6469 6470 <div class="u-overflow-auto"> 6471 <table class="table mini-cart-table dw-mod"> 6472 @RenderBlockList(subBlocks) 6473 </table> 6474 </div> 6475 } 6476 6477 @helper RenderMiniCartOrderLinesBlocks() 6478 { 6479 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList(); 6480 6481 <div class="u-overflow-auto"> 6482 @RenderBlockList(subBlocks) 6483 </div> 6484 } 6485 6486 @helper RenderMiniCartOrderLinesHeader() 6487 { 6488 <thead> 6489 <tr> 6490 <td>&nbsp;</td> 6491 <td>@Translate("Product")</td> 6492 <td class="u-ta-right">@Translate("Qty")</td> 6493 {{#ifCond isEndUser "===" false}} 6494 <td class="u-ta-right" width="120">@Translate("Price")</td> 6495 {{/ifCond}} 6496 </tr> 6497 </thead> 6498 } 6499 6500 @helper RenderMiniCartOrderLinesList() 6501 { 6502 <text> 6503 {{#OrderLines}} 6504 {{#ifCond template "===" "CartOrderline"}} 6505 {{>MiniCartOrderline}} 6506 {{/ifCond}} 6507 {{#ifCond template "===" "CartOrderlineMobile"}} 6508 {{>MiniCartOrderline}} 6509 {{/ifCond}} 6510 {{#ifCond template "===" "CartOrderlineDiscount"}} 6511 {{>MiniCartOrderlineDiscount}} 6512 {{/ifCond}} 6513 {{/OrderLines}} 6514 </text> 6515 } 6516 6517 @helper RenderMiniCartFees() 6518 { 6519 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6520 if (!pointShop) 6521 { 6522 <text> 6523 {{#ifCond userType "===" 'B2B'}} 6524 {{else}} 6525 {{#unless hidePaymentfee}} 6526 <div class="grid"> 6527 <div class="grid__col-6 grid__col--bleed-y"> 6528 {{paymentmethod}} 6529 </div> 6530 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{paymentfee}}</div> 6531 </div> 6532 {{/unless}} 6533 {{/ifCond}} 6534 </text> 6535 } 6536 <text> 6537 {{#ifCond userType "===" 'B2B'}} 6538 {{else}} 6539 {{#unless hideShippingfee}} 6540 <div class="grid"> 6541 <div class="grid__col-6 grid__col--bleed-y"> 6542 {{shippingmethod}} 6543 </div> 6544 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{shippingfee}}</div> 6545 </div> 6546 {{/unless}} 6547 {{/ifCond}} 6548 </text> 6549 <text> 6550 {{#if hasTaxSettings}} 6551 <div class="grid"> 6552 <div class="grid__col-6 grid__col--bleed-y">@Translate("Sales Tax")</div> 6553 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{totaltaxes}}</div> 6554 </div> 6555 {{/if}} 6556 </text> 6557 } 6558 6559 @helper RenderMiniCartFooter() 6560 { 6561 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartFooter").OrderBy(item => item.SortId).ToList(); 6562 6563 <div class="mini-cart__footer u-border-top u-padding-top dw-mod"> 6564 @RenderBlockList(subBlocks) 6565 </div> 6566 } 6567 6568 @helper RenderMiniCartActions() 6569 { 6570 int cartPageId = GetPageIdByNavigationTag("CartPage"); 6571 6572 <button type="button" title="@Translate("Empty cart")" class="btn btn--secondary u-full-width dw-mod u-no-margin u-margin-bottom" onclick="googleEnchantImpressionEmptyCart(); Cart.EmptyCart(event);">@Translate("Empty cart")</button> 6573 <a href="/Default.aspx?ID=@cartPageId" title="@Translate("Go to cart")" class="btn btn--primary u-full-width u-no-margin dw-mod">@Translate("Go to cart")</a> 6574 } 6575 6576 @helper RenderMiniCartPoints() 6577 { 6578 <text> 6579 {{#if earnings}} 6580 <div class="grid"> 6581 <div class="grid__col-6 grid__col--bleed-y">@Translate("Earnings")</div> 6582 <div class="grid__col-6 grid__col--bleed-y grid--align-end"> 6583 <div> 6584 <span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points") 6585 </div> 6586 </div> 6587 </div> 6588 {{/if}} 6589 </text> 6590 } 6591 6592 @helper RenderMiniCartSubTotal() 6593 { 6594 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(Model.Cart.ID); 6595 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6596 if (!pointShop) 6597 { 6598 <text> 6599 {{#ifCond isEndUser "===" false}} 6600 {{#unless hideSubTotal}} 6601 <div class="grid dw-mod u-bold"> 6602 <div class="grid__col-6 grid__col--bleed-y">@Translate("Subtotal")</div> 6603 <div class="grid__col-6 grid__col--bleed-y grid--align-end"> 6604 @if (hasTaxSettings) 6605 { 6606 <text> 6607 {{#ifCond subtotalpricewithouttaxes '!==' '$0.00'}} 6608 {{subtotalpricewithouttaxes}} 6609 {{else}} 6610 {{#ifCond showPrice '===' true}} 6611 {{subtotalpricewithouttaxes}} 6612 {{else}} 6613 <span>-</span> 6614 {{/ifCond}} 6615 {{/ifCond}} 6616 </text> 6617 } 6618 else 6619 { 6620 <text> 6621 {{#ifCond subtotalprice '!==' '$0.00'}} 6622 {{subtotalprice}} 6623 {{else}} 6624 {{#ifCond showPrice '===' true}} 6625 {{subtotalprice}} 6626 {{else}} 6627 <span>-</span> 6628 {{/ifCond}} 6629 {{/ifCond}} 6630 </text> 6631 } 6632 </div> 6633 </div> 6634 {{/unless}} 6635 {{/ifCond}} 6636 </text> 6637 } 6638 } 6639 6640 @helper RenderMiniCartTotal() 6641 { 6642 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6643 6644 <text> 6645 {{#ifCond isEndUser "===" false}} 6646 <div class="mini-cart-totals grid u-border-top u-margin-top dw-mod"> 6647 <div class="grid__col-6">@Translate("Total")</div> 6648 <div class="grid__col-6 grid--align-end"> 6649 <div> 6650 @if (pointShop) 6651 { 6652 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 6653 } 6654 else 6655 { 6656 <text> 6657 {{#ifCond totalprice '!==' '$0.00'}} 6658 {{totalprice}} 6659 {{else}} 6660 {{#ifCond showPrice '===' true}} 6661 {{totalprice}} 6662 {{else}} 6663 <span>-</span> 6664 {{/ifCond}} 6665 {{/ifCond}} 6666 </text> 6667 } 6668 </div> 6669 </div> 6670 </div> 6671 {{/ifCond}} 6672 </text> 6673 } 6674 6675 @helper RenderMiniCartDisclaimer() 6676 { 6677 <text> 6678 {{#if showCheckoutDisclaimer}} 6679 <div class="grid u-margin-bottom u-ta-right"> 6680 <small class="grid__col-12">{{checkoutDisclaimer}}</small> 6681 </div> 6682 {{/if}} 6683 </text> 6684 } 6685 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6686 6687 @using Dynamicweb.Rapido.Blocks.Extensibility 6688 @using Dynamicweb.Rapido.Blocks 6689 @using Dynamicweb.Rapido.Blocks.Components.General 6690 @using Dynamicweb.Rapido.Blocks.Components 6691 @using Dynamicweb.Rapido.Services 6692 6693 @{ 6694 string addToCartNotificationType = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType").SelectedValue : ""; 6695 string addToCartNotificationMiniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown"; 6696 bool addToCartHideCartIcon = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart"); 6697 6698 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !string.IsNullOrEmpty(addToCartNotificationType)) 6699 { 6700 if (addToCartNotificationType == "modal") 6701 { 6702 Block addToCartNotificationModal = new Block 6703 { 6704 Id = "AddToCartNotificationModal", 6705 Template = RenderAddToCartNotificationModal() 6706 }; 6707 6708 Block addToCartNotificationScript = new Block 6709 { 6710 Id = "AddToCartNotificationScript", 6711 Template = RenderAddToCartNotificationModalScript() 6712 }; 6713 BlocksPage.GetBlockPage("Master").Add("MasterTopSnippets", addToCartNotificationModal); 6714 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript); 6715 } 6716 else if (addToCartNotificationType == "toggle" && addToCartNotificationMiniCartLayout != "none" && !addToCartHideCartIcon && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 6717 { 6718 Block addToCartNotificationScript = new Block 6719 { 6720 Id = "AddToCartNotificationScript", 6721 Template = RenderAddToCartNotificationToggleScript() 6722 }; 6723 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript); 6724 } 6725 } 6726 } 6727 6728 @helper RenderAddToCartNotificationModal() 6729 { 6730 <div id="LastAddedProductModal" data-template="LastAddedProductTemplate"></div> 6731 } 6732 6733 @helper RenderAddToCartNotificationModalScript() 6734 { 6735 int cartPageId = GetPageIdByNavigationTag("CartPage"); 6736 6737 <script id="LastAddedProductTemplate" type="text/x-template"> 6738 @{ 6739 6740 Modal lastAddedProduct = new Modal 6741 { 6742 Id = "LastAddedProduct", 6743 Heading = new Heading 6744 { 6745 Level = 2, 6746 Title = Translate("Product is added to the cart") 6747 }, 6748 Width = ModalWidth.Md, 6749 BodyTemplate = RenderModalContent() 6750 }; 6751 6752 lastAddedProduct.AddActions( 6753 new Button 6754 { 6755 ButtonType = ButtonType.Button, 6756 ButtonLayout = ButtonLayout.Secondary, 6757 Title = Translate("Continue shopping"), 6758 CssClass = "u-pull--left u-no-margin btn--sm", 6759 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false" 6760 }, 6761 new Link 6762 { 6763 Href = "/Default.aspx?ID=" + cartPageId, 6764 ButtonLayout = ButtonLayout.Secondary, 6765 CssClass = "u-pull--right u-no-margin btn--sm", 6766 Title = Translate("Proceed to checkout"), 6767 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false" 6768 } 6769 ); 6770 6771 @Render(lastAddedProduct) 6772 } 6773 </script> 6774 <script> 6775 document.addEventListener('addToCart', function (event) { 6776 Cart.ShowLastAddedProductModal(event.detail); 6777 }); 6778 </script> 6779 } 6780 6781 @helper RenderModalContent() 6782 { 6783 <div class="grid"> 6784 <div class="grid__col-2"> 6785 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true }) 6786 </div> 6787 <div class="u-padding grid--align-self-center"> 6788 <span>{{quantity}}</span> x 6789 </div> 6790 <div class="grid__col-auto grid--align-self-center"> 6791 <div>{{productInfo.name}}</div> 6792 {{#if productInfo.variantName}} 6793 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small> 6794 {{/if}} 6795 {{#if productInfo.unitName}} 6796 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small> 6797 {{/if}} 6798 </div> 6799 </div> 6800 } 6801 6802 @helper RenderAddToCartNotificationToggleScript() 6803 { 6804 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 6805 6806 <script> 6807 document.addEventListener('addToCart', function () { 6808 Cart.ToggleMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '@miniCartFeedPageId'); 6809 }); 6810 </script> 6811 } 6812 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6813 6814 @using System 6815 @using System.Web 6816 @using System.Collections.Generic 6817 @using Dynamicweb.Rapido.Blocks.Extensibility 6818 @using Dynamicweb.Rapido.Blocks 6819 @using Dynamicweb.Rapido.Blocks.Components.General 6820 6821 @functions { 6822 BlocksPage footerBlocksPage = BlocksPage.GetBlockPage("Master"); 6823 } 6824 6825 @{ 6826 string footerColumnOneContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Content"); 6827 string footerColumnTwoContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Content"); 6828 string footerColumnThreeContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Content"); 6829 string footerColumnOneHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Header"); 6830 string footerColumnTwoHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Header"); 6831 string footerColumnThreeHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Header"); 6832 6833 Block masterFooterContent = new Block() 6834 { 6835 Id = "MasterFooterContent", 6836 SortId = 10, 6837 Template = RenderFooter(), 6838 SkipRenderBlocksList = true 6839 }; 6840 footerBlocksPage.Add(MasterBlockId.MasterFooter, masterFooterContent); 6841 6842 if (!string.IsNullOrEmpty(footerColumnOneContent) || !string.IsNullOrEmpty(footerColumnOneHeader)) 6843 { 6844 Block masterFooterColumnOne = new Block 6845 { 6846 Id = "MasterFooterColumnOne", 6847 SortId = 10, 6848 Template = RenderFooterColumn(footerColumnOneHeader, footerColumnOneContent), 6849 Design = new Design 6850 { 6851 Size = "auto", 6852 RenderType = RenderType.Column 6853 } 6854 }; 6855 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnOne); 6856 } 6857 6858 if (!string.IsNullOrEmpty(footerColumnTwoContent) || !string.IsNullOrEmpty(footerColumnTwoHeader)) 6859 { 6860 Block masterFooterColumnTwo = new Block 6861 { 6862 Id = "MasterFooterColumnTwo", 6863 SortId = 20, 6864 Template = RenderFooterColumn(footerColumnTwoHeader, footerColumnTwoContent), 6865 Design = new Design 6866 { 6867 Size = "auto", 6868 RenderType = RenderType.Column 6869 } 6870 }; 6871 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnTwo); 6872 } 6873 6874 if (!string.IsNullOrEmpty(footerColumnThreeContent) || !string.IsNullOrEmpty(footerColumnThreeHeader)) 6875 { 6876 Block masterFooterColumnThree = new Block 6877 { 6878 Id = "MasterFooterColumnThree", 6879 SortId = 30, 6880 Template = RenderFooterColumn(footerColumnThreeHeader, footerColumnThreeContent), 6881 Design = new Design 6882 { 6883 Size = "auto", 6884 RenderType = RenderType.Column 6885 } 6886 }; 6887 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnThree); 6888 } 6889 6890 if (Model.Area.Item.GetItem("Layout").GetBoolean("FooterNewsletterSignUp")) 6891 { 6892 Block masterFooterNewsletterSignUp = new Block 6893 { 6894 Id = "MasterFooterNewsletterSignUp", 6895 SortId = 40, 6896 Template = RenderFooterNewsletterSignUp(), 6897 Design = new Design 6898 { 6899 Size = "auto", 6900 RenderType = RenderType.Column 6901 } 6902 }; 6903 footerBlocksPage.Add("MasterFooterContent", masterFooterNewsletterSignUp); 6904 } 6905 6906 if (Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks").Count > 0) 6907 { 6908 Block masterFooterSocialLinks = new Block 6909 { 6910 Id = "MasterFooterSocialLinks", 6911 SortId = 50, 6912 Template = RenderFooterSocialLinks(), 6913 Design = new Design 6914 { 6915 Size = "auto", 6916 RenderType = RenderType.Column 6917 } 6918 }; 6919 footerBlocksPage.Add("MasterFooterContent", masterFooterSocialLinks); 6920 } 6921 6922 if (Model.Area.Item.GetItem("Layout").GetItems("FooterPayments") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterPayments").Count > 0) 6923 { 6924 Block masterFooterPayments = new Block 6925 { 6926 Id = "MasterFooterPayments", 6927 SortId = 60, 6928 Template = RenderFooterPayments(), 6929 Design = new Design 6930 { 6931 Size = "12", 6932 RenderType = RenderType.Column 6933 } 6934 }; 6935 footerBlocksPage.Add("MasterFooterContent", masterFooterPayments); 6936 } 6937 6938 Block masterFooterCopyright = new Block 6939 { 6940 Id = "MasterFooterCopyright", 6941 SortId = 70, 6942 Template = RenderFooterCopyright(), 6943 Design = new Design 6944 { 6945 Size = "12", 6946 RenderType = RenderType.Column 6947 } 6948 }; 6949 footerBlocksPage.Add("MasterFooterContent", masterFooterCopyright); 6950 } 6951 6952 @helper RenderFooter() 6953 { 6954 List<Block> subBlocks = this.footerBlocksPage.GetBlockListById("MasterFooterContent").OrderBy(item => item.SortId).ToList(); 6955 6956 <footer class="footer dw-mod"> 6957 <div class="center-container top-container__center-container dw-mod"> 6958 <div class="grid grid--external-bleed-x"> 6959 @RenderBlockList(subBlocks) 6960 </div> 6961 </div> 6962 </footer> 6963 } 6964 6965 @helper RenderFooterColumn(string header, string content) 6966 { 6967 <h3 class="footer__heading dw-mod">@header</h3> 6968 <div class="footer__content dw-mod"> 6969 @content 6970 </div> 6971 } 6972 6973 @helper RenderFooterNewsletterSignUp() 6974 { 6975 string newsletterSignUpPageId = GetPageIdByNavigationTag("NewsletterSignUp").ToString(); 6976 Form form = new Form { Action = "/Default.aspx", Method = FormMethod.Get, Enctype = FormEnctype.multipart }; 6977 6978 form.Add(new HiddenField { Name = "ID", Value = newsletterSignUpPageId }); 6979 form.Add(new Text { Content = "<p>" + Translate("Sign up if you would like to receive occasional treats from us") + "</p>" }); 6980 form.Add(new TextField { 6981 Id = "NewsletterEmail", Name = "NewsletterEmail", Placeholder = Translate("Your email address"), 6982 Type = TextFieldType.Email, 6983 ActionButton = new Button { 6984 ButtonType = ButtonType.Submit, Id="Submitter", Title = Translate("Go"), OnClick = "Buttons.LockButton(event)", CssClass = "btn--condensed" 6985 } 6986 }); 6987 6988 <h3 class="footer__heading dw-mod">@Translate("Mailing list")</h3> 6989 <div class="footer__content dw-mod"> 6990 @Render(form) 6991 </div> 6992 } 6993 6994 @helper RenderFooterSocialLinks() 6995 { 6996 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3> 6997 <div class="footer__content dw-mod"> 6998 <div class="collection dw-mod"> 6999 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks")) 7000 { 7001 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel; 7002 string socialIconClass = socialIcon.SelectedValue; 7003 string socialIconTitle = socialIcon.SelectedName; 7004 string socialLink = socialitem.GetString("Link"); 7005 7006 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a> 7007 } 7008 </div> 7009 </div> 7010 } 7011 7012 @helper RenderFooterPayments() 7013 { 7014 <div class="footer__content dw-mod"> 7015 <div class="collection dw-mod"> 7016 @foreach (var payment in Model.Area.Item.GetItem("Layout").GetItems("FooterPayments")) 7017 { 7018 var paymentItem = payment.GetValue("CardTypeOrVerifiedPayment") as Dynamicweb.Frontend.ListViewModel; 7019 string paymentImage = null; 7020 string paymentTitle = paymentItem.SelectedName; 7021 ListOptionViewModel selected = paymentItem.SelectedOptions.FirstOrDefault(); 7022 if (selected != null) 7023 { 7024 paymentImage = selected.Icon; 7025 } 7026 7027 <div class="footer__card-type"> 7028 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=60&Compression=75&image=@paymentImage" alt="@paymentTitle" title="@paymentTitle" /> 7029 </div> 7030 } 7031 </div> 7032 </div> 7033 } 7034 7035 @helper RenderFooterCopyright() 7036 { 7037 <div class="grid__col-12 footer__copyright dw-mod"> 7038 <p>@Model.Area.Item.GetItem("Layout").GetString("FooterCopyrightText")</p> 7039 </div> 7040 } 7041 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 7042 7043 @using System 7044 @using System.Web 7045 @using System.Collections.Generic 7046 @using Dynamicweb.Rapido.Blocks.Extensibility 7047 @using Dynamicweb.Rapido.Blocks 7048 @using Dynamicweb.Ecommerce.Common 7049 7050 @{ 7051 BlocksPage referencesBlocksPage = BlocksPage.GetBlockPage("Master"); 7052 7053 Block masterScriptReferences = new Block() 7054 { 7055 Id = "MasterScriptReferences", 7056 SortId = 1, 7057 Template = RenderMasterScriptReferences() 7058 }; 7059 referencesBlocksPage.Add(MasterBlockId.MasterReferences, masterScriptReferences); 7060 } 7061 7062 @helper RenderMasterScriptReferences() { 7063 <script src="/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"></script> 7064 <script src="/Files/Templates/Designs/Rapido/js/master.js?ver=1.2"></script> 7065 7066 if (Model.Area.Item.GetItem("Custom").GetBoolean("UseCustomJavascript")) 7067 { 7068 <script src="/Files/Templates/Designs/Rapido/js/custom.min.js"></script> 7069 PushPromise("/Files/Templates/Designs/Rapido/js/custom.min.js"); 7070 } 7071 7072 PushPromise("/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"); 7073 PushPromise("/Files/Templates/Designs/Rapido/js/master.js?ver=1.2"); 7074 } 7075 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 7076 7077 @using System 7078 @using System.Web 7079 @using System.Collections.Generic 7080 @using Dynamicweb.Rapido.Blocks.Extensibility 7081 @using Dynamicweb.Rapido.Blocks 7082 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7083 @using Dynamicweb.Rapido.Services 7084 7085 @{ 7086 BlocksPage searchBlocksPage = BlocksPage.GetBlockPage("Master"); 7087 bool navigationItemsHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 7088 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID")); 7089 7090 if (!navigationItemsHideSearch || isFavoriteList) 7091 { 7092 Block masterSearchScriptTemplates = new Block() 7093 { 7094 Id = "MasterSearchScriptTemplates", 7095 SortId = 1, 7096 Template = RenderSearchScriptTemplates() 7097 }; 7098 7099 searchBlocksPage.Add(MasterBlockId.MasterBottomSnippets, masterSearchScriptTemplates); 7100 } 7101 } 7102 7103 @helper RenderSearchScriptTemplates() 7104 { 7105 int productsPageId = GetPageIdByNavigationTag("ProductsPage"); 7106 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 7107 bool useFacebookPixel = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID")); 7108 bool useGoogleTagManager = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID")); 7109 bool showPrice = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HidePriceInSearchResults"); 7110 bool showAddToCartButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideAddToCartButton"); 7111 bool showViewButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideViewButton"); 7112 bool showAddToDownloadButton = Pageview.AreaSettings.GetItem("Layout").GetBoolean("ShowAddToDownloadButton"); 7113 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 7114 7115 int userId = (Pageview.User != null) ? Pageview.User.ID : 0; 7116 var user = Dynamicweb.Security.UserManagement.User.GetUserByID(userId); 7117 string usrtype = (user != null) ? user.CustomFieldValues.FirstOrDefault(x => x.CustomField.SystemName == "AccessUser_XPAC_LogInType").Value.ToString() : ""; 7118 7119 string grps = ""; 7120 string userType = ""; 7121 if(user != null) { 7122 foreach (var grp in user.Groups) 7123 { 7124 grps = grp.ID.ToString(); 7125 } 7126 if (grps.Contains("144")) 7127 { 7128 userType = "B2C"; 7129 } 7130 else if (grps.Contains("145")) 7131 { 7132 userType = "B2B"; 7133 } 7134 } 7135 <script id="SearchGroupsTemplate" type="text/x-template"> 7136 {{#.}} 7137 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li> 7138 {{/.}} 7139 </script> 7140 7141 <script id="SearchProductsTemplate" type="text/x-template"> 7142 {{#each .}} 7143 {{#Product}} 7144 {{#ifCond template "!==" "SearchMore"}} 7145 <li class="dropdown__item dropdown__item--seperator dw-mod"> 7146 @if (useFacebookPixel) 7147 { 7148 <text>{{{facebookPixelSearch name number priceDouble currency searchParameter}}}</text> 7149 } 7150 @if (useGoogleTagManager) 7151 { 7152 <text>{{{googleEnchantImpression googleImpression}}}</text> 7153 } 7154 <div> 7155 <a href="{{link}}" 7156 class="js-typeahead-link u-color-inherit u-pull--left" 7157 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" 7158 title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}"> 7159 <div class="u-margin-right u-pull--left {{noimage}} u-hidden-xs u-hidden-xxs"><img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=45&height=36&crop=5&FillCanvas=True&Compression=75&image={{image}}" alt="{{name}}{{#if variantName}}, {{variantName}}{{/if}}"></div> 7160 <div class="u-pull--left"> 7161 <div class="u-bold u-max-w380px mobile-search__width u-truncate-text js-typeahead-name">{{name}}{{#if variantName}}, {{variantName}}{{/if}}</div> 7162 @if (showPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed() && usrtype != "EU") 7163 { 7164 if (pointShopOnly) 7165 { 7166 <text> 7167 {{#if havePointPrice}} 7168 <div> 7169 <span class="u-color--loyalty-points">{{points}}</span> @Translate("points") 7170 </div> 7171 {{else}} 7172 <small class="help-text u-no-margin">@Translate("Not available")</small> 7173 {{/if}} 7174 {{#unless canBePurchasedWithPoints}} 7175 {{#if havePointPrice}} 7176 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 7177 {{/if}} 7178 {{/unless}} 7179 </text> 7180 } 7181 else 7182 { 7183 <text>{{#ifCond priceDouble '>' 0}}</text> 7184 <div>{{price}}</div> 7185 <text>{{/ifCond}}</text> 7186 } 7187 } 7188 </div> 7189 </a> 7190 <div class="u-margin-left u-pull--right"> 7191 @{ 7192 var viewBtn = new Link 7193 { 7194 Href = "{{link}}", 7195 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 7196 ButtonLayout = ButtonLayout.Secondary, 7197 CssClass = "btn--condensed u-no-margin u-w80px js-ignore-click-outside", 7198 Title = Translate("View") 7199 }; 7200 } 7201 @if (showAddToCartButton && Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && usrtype != "EU") 7202 { 7203 if (userType == "B2B") 7204 { 7205 <text>{{#ifCond priceDouble '>' 0}}</text> 7206 <text>{{#if hideAddToCartButton}}</text> 7207 @Render(viewBtn) 7208 <text>{{else}}</text> 7209 @Render(new AddToCartButton 7210 { 7211 HideTitle = true, 7212 ProductId = "{{productId}}", 7213 ProductInfo = "{{productInfo}}", 7214 BuyForPoints = pointShopOnly, 7215 OnClick = "{{facebookPixelAction}}", 7216 CssClass = "u-w80px u-no-margin js-ignore-click-outside", 7217 Icon = new Icon 7218 { 7219 CssClass = "js-ignore-click-outside" 7220 }, 7221 ExtraAttributes = new Dictionary<string, string> { 7222 { "{{disabledBuyButton}}", "" } 7223 } 7224 }) 7225 <text>{{/if}}</text> 7226 <text>{{/ifCond}}</text> 7227 } 7228 else 7229 { 7230 <text>{{#ifCond stock '>' 0}}</text> 7231 <text>{{#ifCond priceDouble '>' 0}}</text> 7232 <text>{{#if hideAddToCartButton}}</text> 7233 @Render(viewBtn) 7234 <text>{{else}}</text> 7235 @Render(new AddToCartButton 7236 { 7237 HideTitle = true, 7238 ProductId = "{{productId}}", 7239 ProductInfo = "{{productInfo}}", 7240 BuyForPoints = pointShopOnly, 7241 OnClick = "{{facebookPixelAction}}", 7242 CssClass = "u-w80px u-no-margin js-ignore-click-outside", 7243 Icon = new Icon 7244 { 7245 CssClass = "js-ignore-click-outside" 7246 }, 7247 ExtraAttributes = new Dictionary<string, string> { 7248 { "{{disabledBuyButton}}", "" } 7249 } 7250 }) 7251 <text>{{/if}}</text> 7252 <text>{{/ifCond}}</text> 7253 <text>{{/ifCond}}</text> 7254 } 7255 } 7256 else if (showViewButton) 7257 { 7258 @Render(viewBtn) 7259 } 7260 @if (showAddToDownloadButton) 7261 { 7262 <button type="button" class="btn btn--primary u-no-margin btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 7263 <i class="fas fa-plus js-button-icon"></i> 7264 </button> 7265 } 7266 </div> 7267 </div> 7268 </li> 7269 {{/ifCond}} 7270 {{#ifCond template "===" "SearchMore"}} 7271 {{>SearchMoreProducts}} 7272 {{/ifCond}} 7273 {{/Product}} 7274 {{else}} 7275 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod"> 7276 @Translate("Your search gave 0 results") 7277 </li> 7278 {{/each}} 7279 </script> 7280 7281 <script id="SearchMoreProducts" type="text/x-template"> 7282 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod"> 7283 <a href="/Default.aspx?ID=@productsPageId&Search={{searchParameter}}&GroupID={{groupId}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> 7284 @Translate("View all") 7285 </a> 7286 </li> 7287 </script> 7288 7289 <script id="SearchMorePages" type="text/x-template"> 7290 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod"> 7291 <a href="/Default.aspx?ID=@contentSearchPageLink&Search={{searchParameter}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> 7292 @Translate("View all") 7293 </a> 7294 </li> 7295 </script> 7296 7297 <script id="SearchPagesTemplate" type="text/x-template"> 7298 {{#each .}} 7299 {{#ifCond template "!==" "SearchMore"}} 7300 <li class="dropdown__item dropdown__item--seperator dropdown__item--no-padding dw-mod"> 7301 <a href="/Default.aspx?ID={{id}}" class="js-typeahead-link dropdown__link u-color-inherit"> 7302 <div class="u-margin-right u-inline"><i class="fa {{icon}} u-w20px u-ta-center"></i></div> 7303 <div class="u-inline u-va-middle"><div class="u-bold u-truncate-text u-max-w210px u-inline-block js-typeahead-name">{{name}}</div></div> 7304 </a> 7305 </li> 7306 {{/ifCond}} 7307 {{#ifCond template "===" "SearchMore"}} 7308 {{>SearchMorePages}} 7309 {{/ifCond}} 7310 {{else}} 7311 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod"> 7312 @Translate("Your search gave 0 results") 7313 </li> 7314 {{/each}} 7315 </script> 7316 7317 <script id="SearchPagesTemplateWrap" type="text/x-template"> 7318 <div class="dropdown__column-header">@Translate("Pages")</div> 7319 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod"> 7320 {{>SearchPagesTemplate}} 7321 </ul> 7322 </script> 7323 7324 <script id="SearchProductsTemplateWrap" type="text/x-template"> 7325 <div class="dropdown__column-header">@Translate("Products")</div> 7326 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod"> 7327 {{>SearchProductsTemplate}} 7328 </ul> 7329 </script> 7330 } 7331 7332 @using Dynamicweb.Rapido.Blocks.Components 7333 @using Dynamicweb.Rapido.Blocks.Components.General 7334 @using Dynamicweb.Rapido.Blocks 7335 @using System.IO 7336 7337 7338 @using Dynamicweb.Rapido.Blocks.Components.General 7339 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7340 7341 7342 @* Component *@ 7343 7344 @helper RenderVariantMatrix(VariantMatrix settings) { 7345 if (settings != null) 7346 { 7347 int productLoopCounter = 0; 7348 int groupCount = 0; 7349 List<VariantOption> firstDimension = new List<VariantOption>(); 7350 List<VariantOption> secondDimension = new List<VariantOption>(); 7351 List<VariantOption> thirdDimension = new List<VariantOption>(); 7352 7353 foreach (VariantGroup variantGroup in settings.GetVariantGroups()) 7354 { 7355 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions()) 7356 { 7357 if (groupCount == 0) { 7358 firstDimension.Add(variantOptions); 7359 } 7360 if (groupCount == 1) 7361 { 7362 secondDimension.Add(variantOptions); 7363 } 7364 if (groupCount == 2) 7365 { 7366 thirdDimension.Add(variantOptions); 7367 } 7368 } 7369 groupCount++; 7370 } 7371 7372 int rowCount = 0; 7373 int columnCount = 0; 7374 7375 <script> 7376 var variantsCollection = []; 7377 </script> 7378 7379 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId"> 7380 @if (groupCount == 1) 7381 { 7382 <tbody> 7383 @foreach (VariantOption firstVariantOption in firstDimension) 7384 { 7385 var variantId = firstVariantOption.Id; 7386 <tr> 7387 <td class="u-bold"> 7388 @firstVariantOption.Name 7389 </td> 7390 <td> 7391 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7392 </td> 7393 </tr> 7394 productLoopCounter++; 7395 } 7396 7397 <tr> 7398 <td>&nbsp;</td> 7399 <td> 7400 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7401 </td> 7402 </tr> 7403 </tbody> 7404 } 7405 @if (groupCount == 2) 7406 { 7407 <thead> 7408 <tr> 7409 <td>&nbsp;</td> 7410 @foreach (VariantOption variant in secondDimension) 7411 { 7412 <td>@variant.Name</td> 7413 } 7414 </tr> 7415 </thead> 7416 <tbody> 7417 @foreach (VariantOption firstVariantOption in firstDimension) 7418 { 7419 string variantId = ""; 7420 columnCount = 0; 7421 7422 <tr> 7423 <td class="u-min-w120px">@firstVariantOption.Name</td> 7424 7425 @foreach (VariantOption secondVariantOption in secondDimension) 7426 { 7427 variantId = firstVariantOption.Id + "." + secondVariantOption.Id; 7428 <td> 7429 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7430 </td> 7431 7432 columnCount++; 7433 7434 productLoopCounter++; 7435 } 7436 7437 <td> 7438 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 7439 </td> 7440 </tr> 7441 7442 rowCount++; 7443 } 7444 7445 @{ 7446 columnCount = 0; 7447 } 7448 7449 <tr> 7450 <td>&nbsp;</td> 7451 @foreach (VariantOption secondVariantOption in secondDimension) 7452 { 7453 <td> 7454 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7455 </td> 7456 7457 columnCount++; 7458 } 7459 <td>&nbsp;</td> 7460 </tr> 7461 </tbody> 7462 } 7463 @if (groupCount == 3) 7464 { 7465 <thead> 7466 <tr> 7467 <td>&nbsp;</td> 7468 @foreach (VariantOption thirdVariantOption in thirdDimension) 7469 { 7470 <td>@thirdVariantOption.Name</td> 7471 } 7472 </tr> 7473 </thead> 7474 <tbody> 7475 @foreach (VariantOption firstVariantOption in firstDimension) 7476 { 7477 int colspan = (thirdDimension.Count + 1); 7478 7479 <tr> 7480 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td> 7481 </tr> 7482 7483 foreach (VariantOption secondVariantOption in secondDimension) 7484 { 7485 string variantId = ""; 7486 columnCount = 0; 7487 7488 <tr> 7489 <td class="u-min-w120px">@secondVariantOption.Name</td> 7490 7491 @foreach (VariantOption thirdVariantOption in thirdDimension) 7492 { 7493 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id; 7494 7495 <td> 7496 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7497 </td> 7498 7499 columnCount++; 7500 productLoopCounter++; 7501 } 7502 7503 <td> 7504 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 7505 </td> 7506 </tr> 7507 rowCount++; 7508 } 7509 } 7510 7511 @{ 7512 columnCount = 0; 7513 } 7514 7515 <tr> 7516 <td>&nbsp;</td> 7517 @foreach (VariantOption thirdVariantOption in thirdDimension) 7518 { 7519 <td> 7520 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7521 </td> 7522 7523 columnCount++; 7524 } 7525 <td>&nbsp;</td> 7526 </tr> 7527 </tbody> 7528 } 7529 </table> 7530 7531 <script> 7532 document.addEventListener("DOMContentLoaded", function (event) { 7533 MatrixUpdateQuantity("@settings.ProductId"); 7534 }); 7535 7536 MatrixUpdateQuantity = function (productId) { 7537 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId); 7538 var allQtyFields = currentMatrix.getElementsByClassName("js-qty"); 7539 7540 var qtyRowArr = []; 7541 var qtyColumnArr = []; 7542 7543 var totalQty = 0; 7544 7545 for (var i = 0; i < allQtyFields.length; i++) { 7546 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0; 7547 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0; 7548 } 7549 7550 for (var i = 0; i < allQtyFields.length; i++) { 7551 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value); 7552 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value); 7553 totalQty += parseFloat(allQtyFields[i].value); 7554 } 7555 7556 //Update row counters 7557 for (var i = 0; i < qtyRowArr.length; i++) { 7558 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 7559 7560 if (qtyRowArr[i] != undefined && qtyCounter != null) { 7561 var currentCount = qtyCounter.innerHTML; 7562 qtyCounter.innerHTML = qtyRowArr[i]; 7563 7564 if (currentCount != qtyCounter.innerHTML) { 7565 qtyCounter.classList.add("qty-field--active"); 7566 } 7567 } 7568 7569 } 7570 7571 //Update column counters 7572 for (var i = 0; i < qtyColumnArr.length; i++) { 7573 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 7574 7575 if (qtyColumnArr[i] != undefined && qtyCounter != null) { 7576 var currentCount = qtyCounter.innerHTML; 7577 qtyCounter.innerHTML = qtyColumnArr[i]; 7578 7579 if (currentCount != qtyCounter.innerHTML) { 7580 qtyCounter.classList.add("qty-field--active"); 7581 } 7582 } 7583 } 7584 7585 if (document.getElementById("TotalQtyCount_" + productId)) { 7586 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty; 7587 } 7588 7589 //Clean up animations 7590 setTimeout(function () { 7591 for (var i = 0; i < qtyRowArr.length; i++) { 7592 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 7593 if (qtyCounter != null) { 7594 qtyCounter.classList.remove("qty-field--active"); 7595 } 7596 } 7597 for (var i = 0; i < qtyColumnArr.length; i++) { 7598 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 7599 if (qtyCounter != null) { 7600 qtyCounter.classList.remove("qty-field--active"); 7601 } 7602 } 7603 }, 1000); 7604 } 7605 </script> 7606 } 7607 } 7608 7609 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount) 7610 { 7611 string loopCount = productLoopCounter.ToString(); 7612 7613 bool combinationFound = false; 7614 double stock = 0; 7615 double quantityValue = 0; 7616 string note = ""; 7617 7618 VariantProduct variantProduct = null; 7619 7620 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct)) 7621 { 7622 stock = variantProduct.Stock; 7623 quantityValue = variantProduct.Quantity; 7624 combinationFound = true; 7625 } 7626 7627 if (combinationFound) 7628 { 7629 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" /> 7630 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" /> 7631 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" /> 7632 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" /> 7633 <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"> 7634 7635 if (stock != 0) 7636 { 7637 <small>@Translate("Stock") @stock</small> 7638 } 7639 7640 <script> 7641 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}'; 7642 variantsCollection.push(variants); 7643 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" ); 7644 </script> 7645 } 7646 else 7647 { 7648 <div class="use-btn-height" style="background-color: #a8a8a8"></div> 7649 } 7650 } 7651 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7652 7653 @* Component *@ 7654 7655 @helper RenderAddToCart(AddToCart settings) 7656 { 7657 //set Id for quantity selector to get it's value from button 7658 if (settings.QuantitySelector != null) 7659 { 7660 if (string.IsNullOrEmpty(settings.QuantitySelector.Id)) 7661 { 7662 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N"); 7663 } 7664 7665 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id; 7666 7667 if (settings.Disabled) 7668 { 7669 settings.QuantitySelector.Disabled = true; 7670 } 7671 7672 if (string.IsNullOrEmpty(settings.QuantitySelector.Name)) 7673 { 7674 settings.QuantitySelector.Name = settings.QuantitySelector.Id; 7675 } 7676 } 7677 7678 if (settings.Disabled) 7679 { 7680 settings.AddButton.Disabled = true; 7681 } 7682 7683 settings.AddButton.CssClass += " btn--condensed"; 7684 7685 //unitsSelector 7686 if (settings.UnitSelector != null) 7687 { 7688 if (settings.Disabled) 7689 { 7690 settings.QuantitySelector.Disabled = true; 7691 } 7692 } 7693 7694 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 7695 @if (settings.UnitSelector != null) 7696 { 7697 @Render(settings.UnitSelector) 7698 } 7699 @if (settings.QuantitySelector != null) 7700 { 7701 @Render(settings.QuantitySelector) 7702 } 7703 @Render(settings.AddButton) 7704 </div> 7705 } 7706 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7707 7708 @* Component *@ 7709 7710 @helper RenderAddToCartButton(AddToCartButton settings) 7711 { 7712 if (!settings.HideTitle) 7713 { 7714 if (string.IsNullOrEmpty(settings.Title)) 7715 { 7716 if (settings.BuyForPoints) 7717 { 7718 settings.Title = Translate("Buy with points"); 7719 } 7720 else 7721 { 7722 settings.Title = Translate("Add to cart"); 7723 } 7724 } 7725 } 7726 else 7727 { 7728 settings.Title = ""; 7729 } 7730 7731 if (settings.Icon == null) 7732 { 7733 settings.Icon = new Icon(); 7734 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After; 7735 } 7736 7737 if (string.IsNullOrEmpty(settings.Icon.Name)) 7738 { 7739 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue; 7740 } 7741 7742 settings.OnClick = "Cart.AddToCart(event, { " + 7743 "id: '" + settings.ProductId + "'," + 7744 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") + 7745 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") + 7746 (settings.BuyForPoints ? "buyForPoints: true," : "") + 7747 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") + 7748 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") + 7749 "});" + settings.OnClick; 7750 7751 @RenderButton(settings) 7752 } 7753 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7754 7755 @* Component *@ 7756 7757 @helper RenderUnitSelector(UnitSelector settings) 7758 { 7759 if (string.IsNullOrEmpty(settings.Id)) 7760 { 7761 settings.Id = Guid.NewGuid().ToString("N"); 7762 } 7763 var disabledClass = settings.Disabled ? "disabled" : ""; 7764 7765 <input type="checkbox" id="@settings.Id" class="dropdown-trigger" /> 7766 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 7767 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@settings.Id">@settings.SelectedOption</label> 7768 <div class="dropdown__content dw-mod"> 7769 @settings.OptionsContent 7770 </div> 7771 <label class="dropdown-trigger-off" for="@settings.Id"></label> 7772 </div> 7773 } 7774 @using System.Reflection 7775 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7776 7777 @* Component *@ 7778 7779 @helper RenderQuantitySelector(QuantitySelector settings) 7780 { 7781 var attributes = new Dictionary<string, string>(); 7782 7783 /*base settings*/ 7784 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 7785 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 7786 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 7787 if (settings.Disabled) { attributes.Add("disabled", "true"); } 7788 if (settings.Required) { attributes.Add("required", "true"); } 7789 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 7790 /*end*/ 7791 7792 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 7793 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 7794 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 7795 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 7796 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 7797 if (settings.Min == null) { settings.Min = 1; } 7798 attributes.Add("min", settings.Min.ToString()); 7799 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); } 7800 if (settings.Value == null) { settings.Value = 1; } 7801 attributes.Add("value", settings.Value.ToString()); 7802 attributes.Add("type", "number"); 7803 7804 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 7805 7806 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 7807 } 7808 @using Dynamicweb.Rapido.Blocks.Components 7809 7810 @using Dynamicweb.Frontend 7811 @using Dynamicweb.Frontend.Devices 7812 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7813 @using Dynamicweb.Rapido.Blocks.Components.General 7814 @using System.Collections.Generic; 7815 7816 @* Component *@ 7817 7818 @helper RenderCustomerCenterList(CustomerCenterList settings) 7819 { 7820 bool isTouchDevice = Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet" ? true : false; 7821 string hideActions = isTouchDevice ? "u-block" : ""; 7822 7823 <table class="table data-list dw-mod"> 7824 @if (settings.GetHeaders().Length > 0) { 7825 <thead> 7826 <tr class="u-bold"> 7827 @foreach (CustomerCenterListHeaderItem header in settings.GetHeaders()) 7828 { 7829 var attributes = new Dictionary<string, string>(); 7830 if (!string.IsNullOrEmpty(header.Id)) { attributes.Add("id", header.Id); } 7831 if (!string.IsNullOrEmpty(header.CssClass)) { attributes.Add("class", header.CssClass); } 7832 attributes.Add("align", header.Align.ToString()); 7833 attributes = attributes.Concat(header.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 7834 7835 <td @ComponentMethods.AddAttributes(attributes)>@header.Title</td> 7836 } 7837 </tr> 7838 </thead> 7839 } 7840 @foreach (CustomerCenterListItem listItem in settings.GetItems()) 7841 { 7842 int columnCount = 0; 7843 int totalColumns = listItem.GetInfoItems().Length; 7844 string rowHasActions = listItem.GetActions().Length > 0 ? "data-list__item--has-actions" : ""; 7845 listItem.Id = !string.IsNullOrEmpty(listItem.Id) ? listItem.Id : Guid.NewGuid().ToString("N"); 7846 7847 var attributes = new Dictionary<string, string>(); 7848 if (!string.IsNullOrEmpty(listItem.Title)) { attributes.Add("title", listItem.Title); }; 7849 7850 attributes = attributes.Concat(listItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 7851 <tbody class="data-list__item @rowHasActions @listItem.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes)> 7852 <tr> 7853 @if (!string.IsNullOrEmpty(listItem.Title) || !string.IsNullOrEmpty(listItem.Description)) { 7854 string onClick = !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 7855 7856 <td rowspan="2" @onClick class="data-list__main-item dw-mod"> 7857 @if (!string.IsNullOrEmpty(listItem.Title)) { 7858 <div class="u-bold">@listItem.Title</div> 7859 } 7860 @if (!string.IsNullOrEmpty(listItem.Description)) { 7861 <div>@listItem.Description</div> 7862 } 7863 </td> 7864 } 7865 7866 @foreach (CustomerCenterListInfoItem infoItem in listItem.GetInfoItems()) 7867 { 7868 var infoAttributes = new Dictionary<string, string>(); 7869 if (!string.IsNullOrEmpty(infoItem.Id)) { infoAttributes.Add("id", infoItem.Id); }; 7870 if (!string.IsNullOrEmpty(infoItem.OnClick)) { infoAttributes.Add("onclick", infoItem.OnClick); }; 7871 infoAttributes.Add("align", infoItem.Align.ToString()); 7872 7873 infoAttributes = infoAttributes.Concat(infoItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 7874 string columnClick = columnCount < (totalColumns-1) && !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 7875 7876 <td @ComponentMethods.AddAttributes(infoAttributes) @columnClick class="data-list__info-item dw-mod"> 7877 @if (!string.IsNullOrEmpty(infoItem.Title)) { 7878 <div>@infoItem.Title</div> 7879 } 7880 @if (!string.IsNullOrEmpty(infoItem.Subtitle)) { 7881 <div><small>@infoItem.Subtitle</small></div> 7882 } 7883 </td> 7884 7885 columnCount++; 7886 } 7887 </tr> 7888 <tr> 7889 <td colspan="7" align="right" class="u-va-bottom u-no-border"> 7890 <div class="data-list__actions @hideActions dw-mod" id="ActionsMenu_@listItem.Id"> 7891 @foreach (ButtonBase action in listItem.GetActions()) 7892 { 7893 action.ButtonLayout = ButtonLayout.LinkClean; 7894 action.Icon.CssClass += " u-full-height"; 7895 action.CssClass += " data-list__action-button link"; 7896 7897 @Render(action) 7898 } 7899 </div> 7900 </td> 7901 </tr> 7902 </tbody> 7903 } 7904 </table> 7905 } 7906 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 7907 7908 @using System 7909 @using System.Web 7910 @using System.Collections.Generic 7911 @using Dynamicweb.Rapido.Blocks.Extensibility 7912 @using Dynamicweb.Rapido.Blocks 7913 7914 @{ 7915 BlocksPage bottomSnippetsBlocksPage = BlocksPage.GetBlockPage("Master"); 7916 7917 Block primaryBottomSnippets = new Block() 7918 { 7919 Id = "MasterJavascriptInitializers", 7920 SortId = 100, 7921 Template = RenderPrimaryBottomSnippets() 7922 }; 7923 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, primaryBottomSnippets); 7924 7925 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 7926 { 7927 Block miniCartPageId = new Block 7928 { 7929 Id = "MiniCartPageId", 7930 Template = RenderMiniCartPageId() 7931 }; 7932 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, miniCartPageId); 7933 } 7934 } 7935 7936 @helper RenderPrimaryBottomSnippets() 7937 { 7938 bool isWireframeMode = Model.Area.Item.GetItem("Settings").GetBoolean("WireframeMode"); 7939 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 7940 7941 if (isWireframeMode) 7942 { 7943 <script> 7944 Wireframe.Init(true); 7945 </script> 7946 } 7947 7948 7949 if (useGoogleTagManager) 7950 { 7951 <script> 7952 document.addEventListener('addToCart', function(event) { 7953 var googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 7954 if (typeof googleImpression == "string") { 7955 googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 7956 } 7957 dataLayer.push({ 7958 'event': 'addToCart', 7959 'ecommerce': { 7960 'currencyCode': googleImpression.currency, 7961 'add': { 7962 'products': [{ 7963 'name': googleImpression.name, 7964 'id': googleImpression.id, 7965 'price': googleImpression.price, 7966 'brand': googleImpression.brand, 7967 'category': googleImpression.category, 7968 'variant': googleImpression.variant, 7969 'quantity': event.detail.quantity 7970 }] 7971 } 7972 } 7973 }); 7974 }); 7975 </script> 7976 } 7977 7978 //if digitalwarehouse 7979 if (Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart")) 7980 { 7981 string cartContextId = Converter.ToString(HttpContext.Current.Application["DownloadCartContext"]); 7982 7983 if (string.IsNullOrEmpty(cartContextId)) 7984 { 7985 var moduleProps = Dynamicweb.Modules.Properties.GetParagraphModuleSettings(GetPageIdByNavigationTag("DownloadCart"), "eCom_CartV2"); 7986 var cartSettings = new Dynamicweb.Ecommerce.Cart.ModuleSettings(moduleProps); 7987 cartContextId = cartSettings.OrderContextID; 7988 HttpContext.Current.Application["DownloadCartContext"] = cartContextId; 7989 } 7990 7991 <script> 7992 let downloadCart = new DownloadCart({ 7993 cartPageId: @GetPageIdByNavigationTag("MiniCartFeed"), 7994 contextId: "@cartContextId", 7995 addButtonText: "@Translate("Add")", 7996 removeButtonText: "@Translate("Remove")" 7997 }); 7998 </script> 7999 } 8000 8001 <!--$$Javascripts--> 8002 } 8003 8004 @helper RenderMiniCartPageId() 8005 { 8006 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 8007 <script> 8008 window.cartId = "@miniCartFeedPageId"; 8009 </script> 8010 } 8011 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 8012 8013 @using System 8014 @using System.Web 8015 @using System.Collections.Generic 8016 @using Dynamicweb.Rapido.Blocks 8017 8018 @{ 8019 BlocksPage masterCustomBlocksPage = BlocksPage.GetBlockPage("Master"); 8020 8021 } 8022 8023 8024 @functions { 8025 public class ManifestIcon 8026 { 8027 public string src { get; set; } 8028 public string type { get; set; } 8029 public string sizes { get; set; } 8030 } 8031 8032 public class Manifest 8033 { 8034 public string name { get; set; } 8035 public string short_name { get; set; } 8036 public string start_url { get; set; } 8037 public string display { get; set; } 8038 public string background_color { get; set; } 8039 public string theme_color { get; set; } 8040 public List<ManifestIcon> icons { get; set; } 8041 } 8042 } 8043 8044 <!DOCTYPE html> 8045 8046 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName"> 8047 8048 8049 8050 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 8051 @RenderBlockList(masterPage.BlocksRoot.BlocksList) 8052 8053 8054 8055 @helper RenderMasterHead() { 8056 List<Block> subBlocks = this.masterPage.GetBlockListById("Head").OrderBy(item => item.SortId).ToList(); 8057 8058 <head> 8059 <!-- Rapido version 3.4.2 --> 8060 8061 @RenderBlockList(subBlocks) 8062 </head> 8063 } 8064 8065 @helper RenderMasterMetadata() { 8066 var swatches = new Dynamicweb.Content.Items.ColorSwatchService(); 8067 var brandColors = swatches.GetColorSwatch(1); 8068 string brandColorOne = brandColors.Palette["BrandColor1"]; 8069 8070 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")) && Model.Area.Item.GetItem("Settings").GetFile("AppIcon") != null) { 8071 Manifest manifest = new Manifest 8072 { 8073 name = Model.Area.Item.GetItem("Settings").GetString("AppName"), 8074 short_name = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppShortName")) ? Model.Area.Item.GetItem("Settings").GetString("AppShortName") : Model.Area.Item.GetItem("Settings").GetString("AppName"), 8075 start_url = "/", 8076 display = "standalone", 8077 background_color = Model.Area.Item.GetItem("Settings").GetString("AppBackgroundColor"), 8078 theme_color = Model.Area.Item.GetItem("Settings").GetString("AppThemeColor") 8079 }; 8080 8081 manifest.icons = new List<ManifestIcon> { 8082 new ManifestIcon { 8083 src = "/Admin/Public/GetImage.ashx?width=192&height=192&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 8084 sizes = "192x192", 8085 type = "image/png" 8086 }, 8087 new ManifestIcon { 8088 src = "/Admin/Public/GetImage.ashx?width=512&height=512&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 8089 sizes = "512x512", 8090 type = "image/png" 8091 }, 8092 new ManifestIcon { 8093 src = "/Admin/Public/GetImage.ashx?width=1024&height=1024&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 8094 sizes = "1024x1024", 8095 type = "image/png" 8096 } 8097 }; 8098 8099 string manifestFilePath = HttpContext.Current.Request.MapPath("/Files/Templates/Designs/Rapido/manifest.json"); 8100 string manifestJSON = Newtonsoft.Json.JsonConvert.SerializeObject(manifest); 8101 string currentManifest = File.ReadAllText(manifestFilePath); 8102 8103 if (manifestJSON != currentManifest) 8104 { 8105 File.WriteAllText(manifestFilePath, manifestJSON); 8106 } 8107 } 8108 8109 <meta charset="utf-8" /> 8110 <title>@Model.Title</title> 8111 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 8112 <meta name="robots" content="index, follow"> 8113 <meta name="theme-color" content="@brandColorOne" /> 8114 8115 if (!Model.MetaTags.Contains("og:image")) { 8116 Pageview.Meta.AddTag("og:image", string.Format("{0}://{1}{2}", Dynamicweb.Context.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, Model.PropertyItem.GetFile("OpenGraphImage"))); 8117 } 8118 8119 if (!Model.MetaTags.Contains("og:description")) { 8120 Pageview.Meta.AddTag("og:description", Model.Description); 8121 } 8122 8123 Pageview.Meta.AddTag("og:title", Model.Title); 8124 Pageview.Meta.AddTag("og:site_name", Model.Name); 8125 Pageview.Meta.AddTag("og:url", HttpContext.Current.Request.Url.ToString()); 8126 Pageview.Meta.AddTag("og:type", "Website"); 8127 8128 if (!string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("FacebookAppID"))) { 8129 Pageview.Meta.AddTag("fb:app_id", Model.Area.Item.GetItem("Settings").GetString("FacebookAppID")); 8130 } 8131 8132 @Model.MetaTags 8133 } 8134 8135 @helper RenderMasterCss() { 8136 var fonts = new string[] { 8137 getFontFamily("Layout", "HeaderFont"), 8138 getFontFamily("Layout", "SubheaderFont"), 8139 getFontFamily("Layout", "TertiaryHeaderFont"), 8140 getFontFamily("Layout", "BodyText"), 8141 getFontFamily("Layout", "Header", "ToolsFont"), 8142 getFontFamily("Layout", "Header", "NavigationFont"), 8143 getFontFamily("Layout", "MobileNavigation", "Font"), 8144 getFontFamily("ProductList", "Facets", "HeaderFont"), 8145 getFontFamily("ProductPage", "PriceFontDesign"), 8146 getFontFamily("Ecommerce", "SaleSticker", "Font"), 8147 getFontFamily("Ecommerce", "NewSticker", "Font"), 8148 getFontFamily("Ecommerce", "CustomSticker", "Font") 8149 }; 8150 8151 string autoCssLink = "/Files/Templates/Designs/Rapido/css/rapido/rapido_" + Model.Area.ID.ToString() + ".min.css?ticks=" + Model.Area.UpdatedDate.Ticks; 8152 string favicon = Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon").Path : "/Files/Images/favicon.png"; 8153 bool useFontAwesomePro = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetBoolean("UseFontAwesomePro"); 8154 string fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomeFree/css/fontawesome-all.min.css"; 8155 if (useFontAwesomePro) 8156 { 8157 fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomePro/css/fontawesome-all.min.css"; 8158 } 8159 8160 //Favicon 8161 <link href="@favicon" rel="icon" type="image/png"> 8162 8163 //Base (Default, wireframe) styles 8164 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/base/base.min.css" type="text/css"> 8165 8166 //Rapido Css from Website Settings 8167 <link rel="stylesheet" id="rapidoCss" href="@autoCssLink" type="text/css"> 8168 8169 //Ignite Css (Custom site specific styles) 8170 <link rel="stylesheet" id="igniteCss" type="text/css" href="/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css"> 8171 8172 //Font awesome 8173 <link rel="stylesheet" href="@fontAwesomeCssLink" type="text/css"> 8174 8175 //Flag icon 8176 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css" type="text/css"> 8177 8178 //Google fonts 8179 var family = string.Join("%7C", fonts.Where(x => !string.IsNullOrEmpty(x)).Distinct().Select(x => string.Format("{0}:100,200,300,400,500,600,700,800,900", x))); 8180 8181 <link href="https://fonts.googleapis.com/css?family=@family" rel="stylesheet"> 8182 8183 PushPromise(favicon); 8184 PushPromise(fontAwesomeCssLink); 8185 PushPromise("/Files/Templates/Designs/Rapido/css/base/base.min.css"); 8186 PushPromise(autoCssLink); 8187 PushPromise("/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css"); 8188 PushPromise("/Files/Images/placeholder.gif"); 8189 PushPromise("/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css"); 8190 } 8191 8192 @helper RenderMasterManifest() { 8193 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName"))) 8194 { 8195 <link rel="manifest" href="/Files/Templates/Designs/Rapido/manifest.json"> 8196 PushPromise("/Files/Templates/Designs/Rapido/manifest.json"); 8197 } 8198 } 8199 8200 @helper RenderMasterBody() { 8201 List<Block> subBlocks = this.masterPage.GetBlockListById("Body").OrderBy(item => item.SortId).ToList(); 8202 string designLayout = Model.PropertyItem.GetItem("CustomSettings") != null ? Model.PropertyItem.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.PropertyItem.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 8203 if (!String.IsNullOrEmpty(designLayout)) { 8204 designLayout = "class=\"" + designLayout + "\""; 8205 } 8206 8207 <body @designLayout> 8208 @RenderBlockList(subBlocks) 8209 8210 8211 8212 8213 </body> 8214 } 8215 8216 @helper RenderMasterHeader() 8217 { 8218 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterHeader").OrderBy(item => item.SortId).ToList(); 8219 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop"); 8220 string stickyTop = isNavigationStickyMenu ? "top-container--sticky" : ""; 8221 8222 <header class="top-container @stickyTop dw-mod" id="Top"> 8223 @RenderBlockList(subBlocks) 8224 </header> 8225 } 8226 8227 @helper RenderMain() 8228 { 8229 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMain").OrderBy(item => item.SortId).ToList(); 8230 8231 <main class="site dw-mod"> 8232 @RenderBlockList(subBlocks) 8233 8234 </main> 8235 } 8236 8237 @helper RenderPageContent() 8238 { 8239 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop"); 8240 string pagePos = isNavigationStickyMenu ? "js-page-pos" : ""; 8241 8242 <div id="Page" class="page @pagePos"> 8243 <section class="center-container content-container dw-mod" id="content"> 8244 8245 @RenderSnippet("Content") 8246 </section> 8247 </div> 8248 } 8249 8250 @* Hack to support nested helpers *@ 8251 @SnippetStart("Content") 8252 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 8253 8254 8255 @using Dynamicweb.Extensibility 8256 @using Dynamicweb.Core 8257 @using Dynamicweb.Rapido.Blocks.Components 8258 @using Dynamicweb.Rapido.Blocks.Components.Articles 8259 @using Dynamicweb.Rapido.Blocks.Components.General 8260 @using Dynamicweb.Rapido.Blocks 8261 @using Dynamicweb.Content.Items 8262 8263 @functions { 8264 BlocksPage articlePage = BlocksPage.GetBlockPage("DynamicArticle"); 8265 8266 public string GetParentSettingsItem(string systemName) { 8267 string item = null; 8268 8269 Dynamicweb.Content.Page current = Dynamicweb.Services.Pages.GetPage(Model.ID); 8270 while (current != null && current.Parent != current) { 8271 var temp = current.Item != null ? current.Item[systemName] : ""; 8272 8273 if (temp != null) { 8274 item = temp.ToString(); 8275 8276 if (!String.IsNullOrEmpty(item) && !String.Equals("default", item, StringComparison.OrdinalIgnoreCase)) { 8277 break; 8278 } 8279 } 8280 8281 current = current.Parent; 8282 } 8283 8284 return item; 8285 } 8286 8287 public string GetArticleCategory(int pageId) 8288 { 8289 string categoryName = null; 8290 8291 //Secure that the article is not in the root folder = Actual has a category 8292 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) { 8293 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) { 8294 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType)) 8295 { 8296 categoryName = Dynamicweb.Services.Pages.GetPage(pageId).Parent.GetDisplayName(); 8297 } 8298 } 8299 } 8300 8301 return categoryName; 8302 } 8303 8304 public string GetArticleCategoryColor(int pageId) 8305 { 8306 string categoryColor = ""; 8307 8308 //Secure that the article is not in the root folder = Actual has a category 8309 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) { 8310 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) { 8311 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType)) 8312 { 8313 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"] != null) 8314 { 8315 var service = new ColorSwatchService(); 8316 categoryColor = Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"].ToString(); 8317 8318 if (!categoryColor.Contains("#")) { 8319 categoryColor = service.GetHexColor(Converter.ToInt32(Model.Area.ID), categoryColor); 8320 } 8321 } 8322 } 8323 } 8324 } 8325 8326 return categoryColor; 8327 } 8328 } 8329 8330 @{ 8331 string listPageId = Converter.ToString(GetPageIdByNavigationTag("DynamicListFeed")); 8332 string parentPageId = Dynamicweb.Services.Pages.GetPage(Model.ID).Parent.ID.ToString(); 8333 string topLayout = Model.Item.GetList("TopLayout") != null ? Model.Item.GetList("TopLayout").SelectedValue : "default"; 8334 topLayout = topLayout == "default" && GetParentSettingsItem("ArticleTopLayout") != null ? GetParentSettingsItem("ArticleTopLayout").ToString().ToLower() : topLayout; 8335 string textLayout = Model.Item.GetList("TextLayout") != null ? Model.Item.GetList("TextLayout").SelectedValue : "default"; 8336 textLayout = textLayout == "default" && GetParentSettingsItem("ArticleTextLayout") != null ? GetParentSettingsItem("ArticleTextLayout").ToString().ToLower() : textLayout; 8337 string imageLayout = Model.Item.GetList("ImageLayout") != null ? Model.Item.GetList("ImageLayout").SelectedValue : "default"; 8338 imageLayout = imageLayout == "default" && GetParentSettingsItem("ArticleImageLayout") != null ? GetParentSettingsItem("ArticleImageLayout").ToString().ToLower() : imageLayout; 8339 8340 string imageColumns = imageLayout == "straight" && textLayout != "full" ? "8" : "12"; 8341 string contentColumns = textLayout != "full" ? "8" : "12"; 8342 8343 int externalParagraphId = Model.Item.GetItem("CTAParagraphLink") != null ? Model.Item.GetItem("CTAParagraphLink").ParagraphID : 0; 8344 8345 ArticleHeaderLayout headerLayout; 8346 8347 switch (topLayout) 8348 { 8349 case "default": 8350 headerLayout = ArticleHeaderLayout.Clean; 8351 break; 8352 case "split": 8353 headerLayout = ArticleHeaderLayout.Split; 8354 break; 8355 case "banner": 8356 headerLayout = ArticleHeaderLayout.Banner; 8357 break; 8358 case "overlay": 8359 headerLayout = ArticleHeaderLayout.Overlay; 8360 break; 8361 default: 8362 headerLayout = ArticleHeaderLayout.Clean; 8363 break; 8364 } 8365 8366 8367 Block articleContainer = new Block 8368 { 8369 Id = "ArticleContainer", 8370 SortId = 10, 8371 Design = new Design 8372 { 8373 RenderType = RenderType.Row 8374 }, 8375 BlocksList = new List<Block> { 8376 new Block { 8377 Id = "ArticleBody", 8378 SortId = 30, 8379 Design = new Design { 8380 RenderType = RenderType.Column, 8381 Size = "12", 8382 HidePadding = true 8383 } 8384 } 8385 } 8386 }; 8387 articlePage.Add(articleContainer); 8388 8389 ButtonLayout topBannerButtonLayout = ButtonLayout.Primary; 8390 8391 switch (Model.Item.GetString("ButtonDesign")) { 8392 case "primary": 8393 topBannerButtonLayout = ButtonLayout.Primary; 8394 break; 8395 case "secondary": 8396 topBannerButtonLayout = ButtonLayout.Secondary; 8397 break; 8398 case "teritary": 8399 topBannerButtonLayout = ButtonLayout.Tertiary; 8400 break; 8401 case "link": 8402 topBannerButtonLayout = ButtonLayout.Link; 8403 break; 8404 } 8405 8406 ArticleHeader topBanner = new ArticleHeader 8407 { 8408 Layout = headerLayout, 8409 Image = new Image { Path = Model.Item.GetFile("Image"), ImageDefault = new ImageSettings { Width = 1920, Height = 640 } }, 8410 Heading = Model.Item.GetString("Title"), 8411 Subheading = Model.Item.GetString("Summary"), 8412 TextColor = "#fff", 8413 Author = Model.Item.GetString("Author"), 8414 Date = Model.Item.GetString("Date"), 8415 Category = GetArticleCategory(Model.ID), 8416 CategoryColor = GetArticleCategoryColor(Model.ID), 8417 Link = Model.Item.GetString("Link"), 8418 LinkText = Model.Item.GetString("LinkText"), 8419 ButtonLayout = topBannerButtonLayout, 8420 RatingScore = Model.Item.GetString("Rating") != null ? Converter.ToInt32(Model.Item.GetList("Rating").SelectedValue) : 0, 8421 RatingOutOf = Model.Item.GetString("Rating") != null ? Model.Item.GetList("Rating").Options.Count : 0, 8422 ExternalParagraphId = externalParagraphId 8423 }; 8424 8425 Block articleTop = new Block 8426 { 8427 Id = "ArticleHead", 8428 SortId = 20, 8429 Component = topBanner, 8430 Design = new Design 8431 { 8432 RenderType = RenderType.Column, 8433 Size = "12", 8434 HidePadding = true, 8435 CssClass = "article-head" 8436 } 8437 }; 8438 articlePage.Add("ArticleContainer", articleTop); 8439 8440 8441 Block articleBodyRow = new Block 8442 { 8443 Id = "ArticleBodyRow", 8444 SortId = 10, 8445 SkipRenderBlocksList = true 8446 }; 8447 articlePage.Add("ArticleBody", articleBodyRow); 8448 8449 8450 if (Model.Item.GetString("Paragraphs") != null) 8451 { 8452 int count = 0; 8453 foreach (var paragraph in Model.Item.GetItems("Paragraphs")) 8454 { 8455 if (!paragraph.GetBoolean("RenderAsQuote")) 8456 { 8457 string enableDropCap = Model.Item.GetString("EnableDropCap") != null ? Model.Item.GetList("EnableDropCap").SelectedValue.ToLower() : "default"; 8458 enableDropCap = enableDropCap == "default" && GetParentSettingsItem("EnableDropCap") != null ? GetParentSettingsItem("EnableDropCap").ToString().ToLower() : enableDropCap; 8459 string text = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : ""; 8460 8461 if (!String.IsNullOrEmpty(text) && enableDropCap == "true" && count == 0 && paragraph.GetString("Text").Substring(0, 3) == "<p>") 8462 { 8463 string firstLetter = paragraph.GetString("Text").Substring(3, 1); 8464 text = paragraph.GetString("Text").Remove(3, 1); 8465 text = text.Insert(3, "<span class=\"article__drop-cap\">" + firstLetter + "</span>"); 8466 } 8467 8468 if (paragraph.GetFile("Image") != null) 8469 { 8470 string imageTitle = !string.IsNullOrEmpty(paragraph.GetString("Heading")) ? paragraph.GetString("Heading") : ""; 8471 8472 Block articleParagraphImage = new Block 8473 { 8474 Id = "ArticleParagraph" + count + "Image", 8475 SortId = (count * 10), 8476 Design = new Design 8477 { 8478 RenderType = RenderType.Column, 8479 Size = imageColumns, 8480 CssClass = "u-color-light--bg u-padding--lg" 8481 } 8482 }; 8483 8484 if (imageLayout == "banner") 8485 { 8486 ArticleBanner banner = new ArticleBanner 8487 { 8488 Image = new Image { Path = paragraph.GetFile("Image"), ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, Caption = paragraph.GetString("ImageCaption") }, 8489 Heading = imageTitle, 8490 UseFilters = false 8491 }; 8492 articleParagraphImage.Component = banner; 8493 } 8494 else 8495 { 8496 ArticleImage image = new ArticleImage 8497 { 8498 Image = new Image 8499 { 8500 Path = paragraph.GetFile("Image"), 8501 Title = imageTitle, 8502 ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, 8503 Caption = paragraph.GetString("ImageCaption") 8504 } 8505 }; 8506 articleParagraphImage.Component = image; 8507 } 8508 8509 articlePage.Add("ArticleBodyRow", articleParagraphImage); 8510 } 8511 8512 if (!String.IsNullOrEmpty(paragraph.GetString("VideoURL"))) 8513 { 8514 Block articleParagraphVideo = new Block 8515 { 8516 Id = "ArticleParagraph" + count + "Video", 8517 SortId = (count * 10) + 1, 8518 Component = new ArticleVideo { Url = paragraph.GetString("VideoURL"), AutoPlay = "false" }, 8519 Design = new Design 8520 { 8521 RenderType = RenderType.Column, 8522 Size = imageColumns, 8523 CssClass = "u-color-light--bg u-padding--lg" 8524 } 8525 }; 8526 articlePage.Add("ArticleBodyRow", articleParagraphVideo); 8527 } 8528 8529 if (!String.IsNullOrEmpty(paragraph.GetString("Heading"))) 8530 { 8531 Block articleParagraphHeader = new Block 8532 { 8533 Id = "ArticleParagraph" + count + "Heading", 8534 SortId = (count * 10) + 2, 8535 Component = new ArticleSubHeader { Title = paragraph.GetString("Heading") }, 8536 Design = new Design 8537 { 8538 RenderType = RenderType.Column, 8539 Size = contentColumns, 8540 CssClass = "u-color-light--bg u-padding--lg" 8541 } 8542 }; 8543 articlePage.Add("ArticleBodyRow", articleParagraphHeader); 8544 } 8545 8546 if (!String.IsNullOrEmpty(text)) 8547 { 8548 Block articleParagraphText = new Block 8549 { 8550 Id = "ArticleParagraph" + count + "Text", 8551 SortId = (count * 10) + 3, 8552 Component = new ArticleText { Text = text }, 8553 Design = new Design 8554 { 8555 RenderType = RenderType.Column, 8556 Size = contentColumns, 8557 CssClass = "u-color-light--bg u-padding--lg" 8558 } 8559 }; 8560 8561 articlePage.Add("ArticleBodyRow", articleParagraphText); 8562 } 8563 } 8564 else 8565 { 8566 if (!String.IsNullOrEmpty(paragraph.GetString("Text"))) 8567 { 8568 string quoteText = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : ""; 8569 string quoteAuthor = paragraph.GetString("Heading") != null ? paragraph.GetString("Heading") : ""; 8570 8571 Block articleParagraphQuote = new Block 8572 { 8573 Id = "ArticleParagraph" + count + "Quote", 8574 SortId = (count * 10) + 3, 8575 Component = new ArticleQuote { Image = new Image { Path = paragraph.GetFile("Image") }, Text = quoteText, Author = quoteAuthor }, 8576 Design = new Design 8577 { 8578 RenderType = RenderType.Column, 8579 Size = contentColumns, 8580 CssClass = "u-color-light--bg u-padding--lg" 8581 } 8582 }; 8583 articlePage.Add("ArticleBodyRow", articleParagraphQuote); 8584 } 8585 } 8586 8587 count++; 8588 } 8589 } 8590 8591 articleBodyRow.Component = new ArticleBodyRow { SubBlocks = articleBodyRow.BlocksList, TopLayout = topLayout, TextLayout = textLayout }; 8592 8593 8594 //Related 8595 string showRelatedArtices = Model.Item.GetString("ShowRelatedArticles") != null ? Model.Item.GetList("ShowRelatedArticles").SelectedValue.ToLower() : "default"; 8596 showRelatedArtices = showRelatedArtices == "default" && GetParentSettingsItem("ShowRelatedArticles") != null ? GetParentSettingsItem("ShowRelatedArticles").ToString().ToLower() : showRelatedArtices; 8597 8598 if (showRelatedArtices == "true") 8599 { 8600 Block articleRelated = new Block 8601 { 8602 Id = "ArticleRelated", 8603 SortId = 30, 8604 Component = new ArticleRelated { Title = Translate("Related articles"), FeedPageId = listPageId, Query = "sourceType=Page&sourcePage=" + parentPageId, PageSize = 4, CurrentPageId = Model.ID.ToString() }, 8605 Design = new Design 8606 { 8607 RenderType = RenderType.Column, 8608 Size = "12" 8609 } 8610 }; 8611 articlePage.Add("ArticleContainer", articleRelated); 8612 } 8613 } 8614 8615 8616 @using System 8617 @using System.Web 8618 @using System.Collections.Generic 8619 @using Dynamicweb.Rapido.Blocks 8620 8621 @{ 8622 BlocksPage dynamicArticleCustomBlocksPage = BlocksPage.GetBlockPage("DynamicArticle"); 8623 8624 } 8625 8626 8627 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 8628 @RenderBlockList(articlePage.BlocksRoot.BlocksList) 8629 @SnippetEnd("Content") 8630 8631 @helper RenderIosTabletFix() { 8632 if (Pageview.Device != Dynamicweb.Frontend.Devices.DeviceType.Tablet && Pageview.Platform != Dynamicweb.Frontend.Devices.PlatformType.Ios) 8633 { 8634 <script> 8635 let isIpadIOS = (/iPad/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream; 8636 if (isIpadIOS) { 8637 var separator = (window.location.href.indexOf("?") === -1) ? "?" : "&"; 8638 window.location.href = window.location.href + separator + "DeviceType=Tablet&PlatformType=Ios"; 8639 } 8640 </script> 8641 } 8642 } 8643 8644 8645 8646 </html> 8647 8648