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

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