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