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_8daea0dd85e44e61b35b8979fb83c190.Execute() in D:\dynamicweb.net\Solutions\Mennt\Skadedyrbutikken.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 8951
   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 if (Pageview.Area.ID != 25){ 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 4917 4918 if (Path.GetExtension(logo).ToLower() != ".svg") 4919 { 4920 int logoHeight = Model.Area.Item.GetItem("Layout").GetInt32("LogoHeight"); 4921 logoHeight = logoHeight > 0 && Pageview.Device.ToString() != "Mobile" ? logoHeight : 40; 4922 logo = "/Admin/Public/GetImage.ashx?height=" + Converter.ToString(logoHeight) + "&amp;crop=5&amp;Compression=75&amp;image=" + logo; 4923 } 4924 else 4925 { 4926 logo = HttpUtility.UrlDecode(logo); 4927 } 4928 4929 <div class="logo @alignClass dw-mod"> 4930 <a href="/Default.aspx?ID=@firstPageId" class="logo__img dw-mod u-block"> 4931 @if (Model.Area.Item.GetItem("Layout").GetFile("LogoImage") != null){ 4932 <img class="grid__cell-img logo__img dw-mod" src="@logo" alt="@Translate("Logo")" /> 4933 } 4934 else { 4935 <div class="grid__cell-img logo__img dw-mod" style="color:black; font-weight: bold; font-size: 36px;">Homies.no</div> 4936 } 4937 </a> 4938 </div> 4939 } 4940 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 4941 4942 @using System 4943 @using System.Web 4944 @using Dynamicweb.Rapido.Blocks.Extensibility 4945 @using Dynamicweb.Rapido.Blocks 4946 4947 @functions { 4948 bool isMegaMenu; 4949 } 4950 4951 @{ 4952 isMegaMenu = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu") != null ? Converter.ToBoolean(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu").SelectedValue) : false; 4953 Block masterDesktopMenu = new Block 4954 { 4955 Id = "MasterDesktopMenu", 4956 SortId = 10, 4957 Template = RenderDesktopMenu(), 4958 Design = new Design 4959 { 4960 Size = "auto", 4961 HidePadding = true, 4962 RenderType = RenderType.Column 4963 } 4964 }; 4965 4966 if (isMegaMenu) 4967 { 4968 masterDesktopMenu.Design.CssClass = "u-reset-position"; 4969 } 4970 4971 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopMenu); 4972 } 4973 4974 @helper RenderDesktopMenu() 4975 { 4976 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 4977 string menuAlignment = topLayout == "minimal-right" ? "grid--align-self-end" : ""; 4978 menuAlignment = topLayout == "minimal-center" ? "grid--align-self-center" : topLayout; 4979 string megamenuPromotionImage = Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage").PathUrlEncoded : ""; 4980 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 4981 bool showOnlyHeaders = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOnlyHeaders"); 4982 int startLevel = renderPagesInToolBar ? 1 : 0; 4983 4984 string promotionLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("MegamenuPromotionLink"); 4985 4986 <div class="grid__cell u-flex @(isMegaMenu ? "u-reset-position" : "") @menuAlignment"> 4987 @if (!isMegaMenu) 4988 { 4989 @RenderNavigation(new 4990 { 4991 id = "topnavigation", 4992 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap", 4993 startLevel = startLevel, 4994 ecomStartLevel = startLevel + 1, 4995 endlevel = 5, 4996 expandmode = "all", 4997 template = "BaseMenuWithDropdown.xslt" 4998 }); 4999 } 5000 else 5001 { 5002 @RenderNavigation(new 5003 { 5004 id = "topnavigation", 5005 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap", 5006 startLevel = startLevel, 5007 ecomStartLevel = startLevel + 1, 5008 endlevel = 5, 5009 promotionImage = megamenuPromotionImage, 5010 promotionLink = promotionLink, 5011 expandmode = "all", 5012 showOnlyHeaders = showOnlyHeaders.ToString().ToLower(), 5013 template = "BaseMegaMenu.xslt" 5014 }); 5015 } 5016 </div> 5017 } 5018 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5019 5020 @using System 5021 @using System.Web 5022 @using Dynamicweb.Rapido.Blocks.Extensibility 5023 @using Dynamicweb.Rapido.Blocks 5024 5025 @{ 5026 Block masterDesktopActionsMenu = new Block 5027 { 5028 Id = "MasterDesktopActionsMenu", 5029 SortId = 10, 5030 Template = RenderDesktopActionsMenu(), 5031 Design = new Design 5032 { 5033 CssClass = "u-flex" 5034 }, 5035 SkipRenderBlocksList = true 5036 5037 }; 5038 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopActionsMenu); 5039 5040 if (!string.IsNullOrWhiteSpace(Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink"))) 5041 { 5042 Block masterDesktopActionsHeaderButton = new Block 5043 { 5044 Id = "MasterDesktopActionsHeaderButton", 5045 SortId = 60, 5046 Template = RenderHeaderButton() 5047 }; 5048 masterDesktopActionsMenu.Add(masterDesktopActionsHeaderButton); 5049 } 5050 } 5051 5052 @helper RenderDesktopActionsMenu() 5053 { 5054 List<Block> subBlocks = this.headerBlocksPage.GetBlockListById("MasterDesktopActionsMenu").OrderBy(item => item.SortId).ToList(); 5055 5056 <ul class="menu u-flex dw-mod"> 5057 5058 <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> 5059 5060 @RenderBlockList(subBlocks) 5061 </ul> 5062 } 5063 5064 @helper RenderHeaderButton() 5065 { 5066 string headerButtonText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonText"); 5067 string headerButtonLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink"); 5068 string headerButtonType = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType") != null ? "btn--" + Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType").SelectedName.ToLower() : ""; 5069 5070 <li class="menu__item menu__item--horizontal menu--clean dw-mod"> 5071 <a class="btn @headerButtonType dw-mod u-no-margin u-margin-left" href="@headerButtonLink">@headerButtonText</a> 5072 </li> 5073 } 5074 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5075 5076 @using System 5077 @using System.Web 5078 @using Dynamicweb.Core; 5079 @using System.Text.RegularExpressions 5080 @using Dynamicweb.Rapido.Blocks.Extensibility 5081 @using Dynamicweb.Rapido.Blocks 5082 5083 @{ 5084 Block masterDesktopActionsMenuLanguageSelector = new Block 5085 { 5086 Id = "MasterDesktopActionsMenuLanguageSelector", 5087 SortId = 40, 5088 Template = RenderLanguageSelector() 5089 }; 5090 5091 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuLanguageSelector); 5092 } 5093 5094 @helper RenderLanguageSelector() 5095 { 5096 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5097 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5098 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5099 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() : ""; 5100 5101 if (Model.Languages.Count > 1) 5102 { 5103 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon is-dropdown is-dropdown--no-icon dw-mod"> 5104 <div class="@menuLinkClass dw-mod" title="@Translate("Language")"> 5105 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue fa-1_5x"></i> 5106 </div> 5107 <div class="menu menu--dropdown menu--dropdown-right languages-dropdown dw-mod grid__cell"> 5108 @foreach (var lang in Model.Languages) 5109 { 5110 string widthClass = "menu__item--fixed-width"; 5111 string langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " u-margin-right\"></span>" + lang.Name; 5112 string cultureName = Regex.Replace(Dynamicweb.Services.Areas.GetArea(lang.ID).CultureInfo.NativeName, @" ?\(.*?\)", string.Empty); 5113 cultureName = char.ToUpper(cultureName[0]) + cultureName.Substring(1); 5114 5115 if (languageViewType == "flag-culture") 5116 { 5117 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span> " + cultureName; 5118 } 5119 5120 if (languageViewType == "flag") 5121 { 5122 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span>"; 5123 widthClass = ""; 5124 } 5125 5126 if (languageViewType == "name") 5127 { 5128 langInfo = lang.Name; 5129 } 5130 5131 if (languageViewType == "culture") 5132 { 5133 langInfo = cultureName; 5134 widthClass = ""; 5135 } 5136 5137 <div class="menu__item dw-mod @widthClass"> 5138 <a href="/Default.aspx?AreaID=@Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID" class="menu-dropdown__link dw-mod">@langInfo</a> 5139 </div> 5140 } 5141 </div> 5142 </li> 5143 } 5144 } 5145 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5146 5147 @using System 5148 @using System.Web 5149 @using Dynamicweb.Rapido.Blocks.Extensibility 5150 @using Dynamicweb.Rapido.Blocks 5151 5152 @{ 5153 Block masterDesktopActionsMenuSignIn = new Block 5154 { 5155 Id = "MasterDesktopActionsMenuSignIn", 5156 SortId = 20, 5157 Template = RenderSignIn() 5158 }; 5159 5160 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuSignIn); 5161 } 5162 5163 @helper RenderSignIn() 5164 { 5165 bool navigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn"); 5166 string userInitials = ""; 5167 int pageId = Model.TopPage.ID; 5168 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount"); 5169 int myDashboardPageId = GetPageIdByNavigationTag("CustomerDashboard"); 5170 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile"); 5171 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders"); 5172 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 5173 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards"); 5174 int myOrderDraftsPageId = GetPageIdByNavigationTag("OrderDraft"); 5175 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 5176 int recurringOrderPageId = GetPageIdByNavigationTag("RecurringOrders"); 5177 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount"); 5178 bool hideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile"); 5179 bool hideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders"); 5180 bool hideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards"); 5181 bool hideMyOrderDraftsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrderDrafts"); 5182 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites"); 5183 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink"); 5184 5185 string linkStart = "/Default.aspx?ID="; 5186 if (Model.CurrentUser.ID <= 0) 5187 { 5188 linkStart += signInProfilePageId + "&RedirectPageId="; 5189 } 5190 5191 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery"; 5192 string myProfilePageLink = linkStart + myProfilePageId; 5193 string myOrdersPageLink = linkStart + myOrdersPageId; 5194 string myFavoritesPageLink = linkStart + myFavoritesPageId; 5195 string mySavedCardsPageLink = linkStart + mySavedCardsPageId; 5196 string myOrderDraftsLink = linkStart + myOrderDraftsPageId; 5197 string myRecurringOrderLink = linkStart + recurringOrderPageId; 5198 5199 string profileIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue : "fa fa-user"; 5200 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"; 5201 string orderDraftsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard"; 5202 5203 if (Model.CurrentUser.ID != 0) 5204 { 5205 userInitials = Dynamicweb.Rapido.Services.User.GetInitials(Model.CurrentUser.Name, Model.CurrentUser.FirstName, Model.CurrentUser.LastName, Model.CurrentUser.Email, Model.CurrentUser.UserName); 5206 } 5207 5208 if (!navigationItemsHideSignIn) 5209 { 5210 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5211 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu__item--clean"; 5212 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5213 5214 <li class="menu__item menu__item--horizontal menu__item menu__item--icon @liClasses is-dropdown is-dropdown--no-icon dw-mod"> 5215 <div class="@menuLinkClass dw-mod" style="padding: 1rem 0rem 1rem 1rem;"> @*Mennt*@ 5216 @if (Model.CurrentUser.ID <= 0) 5217 { 5218 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue fa-1_5x" title="@Translate("Sign in")"></i> 5219 } 5220 else 5221 { 5222 <a href="/default.aspx?ID=@myDashboardPageId" class="u-color-inherit" title="@Translate("Customer center")"><div class="circle-icon-btn">@userInitials.ToUpper()</div></a> 5223 } 5224 </div> 5225 <div class="menu menu--dropdown menu--dropdown-right menu--sign-in grid__cell dw-mod"> 5226 <ul class="list list--clean dw-mod"> 5227 @if (Model.CurrentUser.ID <= 0) 5228 { 5229 <li> 5230 <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> 5231 </li> 5232 5233 if (!hideCreateAccountLink) 5234 { 5235 @RenderListItem("/default.aspx?ID=" + createAccountPageId, Translate("Create account")); 5236 } 5237 if (!hideForgotPasswordLink) 5238 { 5239 @RenderListItem(forgotPasswordPageLink, Translate("Forgot your password?")) 5240 } 5241 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink) 5242 { 5243 @RenderSeparator() 5244 } 5245 } 5246 @if (!hideMyProfileLink) 5247 { 5248 @RenderListItem(myProfilePageLink, Translate("My Profile"), profileIcon) 5249 } 5250 @if (!hideMyOrdersLink) 5251 { 5252 @RenderListItem(myOrdersPageLink, Translate("My Orders"), "fas fa-list") 5253 } 5254 @if (!hideMyFavoritesLink) 5255 { 5256 @RenderListItem(myFavoritesPageLink, Translate("My Favorites"), favoritesIcon) 5257 } 5258 @if (!hideMySavedCardsLink) 5259 { 5260 @RenderListItem(mySavedCardsPageLink, Translate("My Saved cards"), "fas fa-credit-card") 5261 } 5262 @if (!hideMyOrderDraftsLink) 5263 { 5264 @RenderListItem(myOrderDraftsLink, Translate("My Order drafts"), orderDraftsIcon) 5265 } 5266 @if (Model.Area.ID == 24) 5267 { 5268 @RenderListItem(myRecurringOrderLink, Translate("Gjentagende ordre"), orderDraftsIcon) 5269 } 5270 @if (Model.CurrentUser.ID > 0) 5271 { 5272 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink) 5273 { 5274 @RenderSeparator() 5275 } 5276 5277 //Check if impersonation is on 5278 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0) 5279 { 5280 <li> 5281 <div class="list__link dw-mod" onclick="document.getElementById('StopImpersonationModalTrigger').checked = true;"> 5282 @Translate("Sign out") 5283 </div> 5284 </li> 5285 } else { 5286 @RenderListItem("/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, Translate("Sign out")) 5287 } 5288 } 5289 </ul> 5290 </div> 5291 </li> 5292 } 5293 } 5294 5295 @helper RenderListItem(string link, string text, string icon = null) { 5296 <li> 5297 <a href="@link" class="list__link dw-mod" onclick="RememberState.SetCookie('useAnotherAddress', false)"> 5298 @if (!string.IsNullOrEmpty(icon)){<i class="@icon u-margin-right"></i>}@text 5299 </a> 5300 </li> 5301 } 5302 5303 @helper RenderSeparator() 5304 { 5305 <li class="list__seperator dw-mod"></li> 5306 } 5307 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5308 5309 @using System 5310 @using System.Web 5311 @using Dynamicweb.Rapido.Blocks.Extensibility 5312 @using Dynamicweb.Rapido.Blocks 5313 5314 @{ 5315 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideFavorites"); 5316 5317 Block masterDesktopActionsMenuFavorites = new Block 5318 { 5319 Id = "MasterDesktopActionsMenuFavorites", 5320 SortId = 30, 5321 Template = RenderFavorites() 5322 }; 5323 5324 if (!hideMyFavoritesLink && Model.CurrentUser.ID > 0) 5325 { 5326 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuFavorites); 5327 } 5328 } 5329 5330 @helper RenderFavorites() 5331 { 5332 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites"); 5333 string myFavoritesPageLink = "/Default.aspx?ID=" + myFavoritesPageId; 5334 5335 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5336 string liClasses = topLayout != "normal" && topLayout != "splitted-center" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5337 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5338 5339 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5340 <a href="@myFavoritesPageLink" class="@menuLinkClass dw-mod" title="@Translate("Favorites")"> 5341 <i class="fas fa-@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue fa-1_5x"></i> 5342 </a> 5343 </li> 5344 } 5345 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5346 5347 @using System 5348 @using System.Web 5349 @using Dynamicweb.Rapido.Blocks.Extensibility 5350 @using Dynamicweb.Rapido.Blocks 5351 @using Dynamicweb.Rapido.Services 5352 5353 @{ 5354 bool hideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart"); 5355 string miniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown"; 5356 5357 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !hideCart) 5358 { 5359 Block masterDesktopActionsMenuMiniCart = new Block 5360 { 5361 Id = "MasterDesktopActionsMenuMiniCart", 5362 SortId = 60, 5363 Template = RenderMiniCart(miniCartLayout == "dropdown"), 5364 SkipRenderBlocksList = true, 5365 BlocksList = new List<Block>() 5366 }; 5367 5368 Block miniCartCounterScriptTemplate = new Block 5369 { 5370 Id = "MiniCartCounterScriptTemplate", 5371 Template = RenderMiniCartCounterContent() 5372 }; 5373 5374 //dropdown layout is default 5375 RazorEngine.Templating.TemplateWriter layoutTemplate; 5376 RazorEngine.Templating.TemplateWriter miniCartTriggerTemplate; 5377 5378 switch (miniCartLayout) 5379 { 5380 case "dropdown": 5381 layoutTemplate = RenderMiniCartDropdownLayout(); 5382 miniCartTriggerTemplate = RenderMiniCartTriggerLink(); 5383 break; 5384 case "panel": 5385 layoutTemplate = RenderMiniCartPanelLayout(); 5386 miniCartTriggerTemplate = RenderMiniCartTriggerLabel(); 5387 break; 5388 case "modal": 5389 layoutTemplate = RenderMiniCartModalLayout(); 5390 miniCartTriggerTemplate = RenderMiniCartTriggerLabel(); 5391 break; 5392 case "none": 5393 default: 5394 layoutTemplate = RenderMiniCartDropdownLayout(); 5395 miniCartTriggerTemplate = RenderMiniCartTriggerLink(); 5396 break; 5397 } 5398 5399 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block 5400 { 5401 Id = "MiniCartTrigger", 5402 Template = miniCartTriggerTemplate 5403 }); 5404 5405 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 5406 { 5407 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block 5408 { 5409 Id = "MiniCartLayout", 5410 Template = layoutTemplate 5411 }); 5412 } 5413 5414 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuMiniCart); 5415 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate); 5416 } 5417 5418 if (hideCart && Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 5419 { 5420 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block { 5421 Id = "CartInitialization" 5422 }); 5423 } 5424 } 5425 5426 @helper RenderMiniCart(bool hasMouseEnterEvent) 5427 { 5428 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterDesktopActionsMenuMiniCart").OrderBy(item => item.SortId).ToList(); 5429 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5430 string liClasses = topLayout != "normal" ? "menu__item--top-level" : "menu--clean"; 5431 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5432 string mouseEvent = ""; 5433 string id = "MiniCart"; 5434 if (hasMouseEnterEvent) 5435 { 5436 mouseEvent = "onmouseenter=\"Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=" + miniCartFeedPageId + "&feedType=MiniCart')\""; 5437 id = "miniCartTrigger"; 5438 } 5439 <li class="menu__item menu__item--horizontal menu__item--icon @liClasses dw-mod" id="@id" @mouseEvent> 5440 @RenderBlockList(subBlocks) 5441 </li> 5442 } 5443 5444 @helper RenderMiniCartTriggerLabel() 5445 { 5446 int cartPageId = GetPageIdByNavigationTag("CartPage"); 5447 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart"; 5448 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5449 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5450 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5451 5452 <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*@ 5453 <div class="u-inline u-position-relative"> 5454 <i class="@cartIcon fa-1_5x"></i> 5455 @RenderMiniCartCounter() 5456 </div> 5457 </div> 5458 } 5459 5460 @helper RenderMiniCartTriggerLink() 5461 { 5462 int cartPageId = GetPageIdByNavigationTag("CartPage"); 5463 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart"; 5464 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5465 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5466 5467 <a href="/Default.aspx?ID=@cartPageId&Purge=True" class="@menuLinkClass menu__item--icon dw-mod js-mini-cart-button" title="@Translate("Cart")"> 5468 <span class="u-inline u-position-relative"> 5469 <i class="@cartIcon fa-1_5x"></i> 5470 @RenderMiniCartCounter() 5471 </span> 5472 </a> 5473 } 5474 5475 @helper RenderMiniCartCounter() 5476 { 5477 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5478 string cartProductsCount = Model.Cart.TotalProductsCount.ToString(); 5479 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5480 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice"); 5481 string cartProductsTotalPrice = showPrice && Model.Cart.TotalPrice != null ? Model.Cart.TotalPrice.Price.Formatted : ""; 5482 cartProductsTotalPrice = counterPosition == "right" ? cartProductsTotalPrice : ""; 5483 5484 if (showPrice && counterPosition == "right") 5485 { 5486 cartProductsCount = Translate("Cart") + " (" + cartProductsCount + ")"; 5487 } 5488 5489 <span class="mini-cart__counter @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod"> 5490 <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"> 5491 <span class="js-mini-cart-counter-content" data-count="@Model.Cart.TotalProductsCount.ToString()"> 5492 @cartProductsCount @cartProductsTotalPrice 5493 </span> 5494 </span> 5495 </span> 5496 } 5497 5498 @helper RenderMiniCartCounterContent() 5499 { 5500 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice"); 5501 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5502 bool showPriceInMiniCartCounter = Pageview.Device.ToString() != "Mobile" && counterPosition == "right" && showPrice; 5503 5504 <script id="MiniCartCounterContent" type="text/x-template"> 5505 {{#.}} 5506 <span class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}"> 5507 @if (showPriceInMiniCartCounter) 5508 { 5509 @Translate("Cart")<text>({{numberofproducts}}) {{totalprice}}</text> 5510 } 5511 else 5512 { 5513 <text>{{numberofproducts}}</text> 5514 } 5515 </span> 5516 {{/.}} 5517 </script> 5518 } 5519 5520 @helper RenderMiniCartDropdownLayout() 5521 { 5522 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5523 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5524 5525 <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"> 5526 <div class="mini-cart-dropdown__inner dw-mod"> 5527 <h3 class="u-ta-center dw-mod">@Translate("Shopping cart")</h3> 5528 <div class="mini-cart-dropdown__body u-flex dw-mod"> 5529 <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> 5530 </div> 5531 </div> 5532 </div> 5533 } 5534 5535 @helper RenderMiniCartPanelLayout() 5536 { 5537 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5538 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5539 5540 <div class="mini-cart grid__cell dw-mod"> 5541 <input type="checkbox" id="miniCartTrigger" class="panel-trigger" /> 5542 <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"> 5543 <label for="miniCartTrigger" class="panel__close-btn" title="@Translate("Close panel")"><i class="fas fa-times"></i></label> 5544 <div class="panel__content u-full-width dw-mod"> 5545 <h3 class="panel__header dw-mod u-margin-bottom u-ta-center">@Translate("Shopping cart")</h3> 5546 <div class="panel__content-body panel__content-body--cart dw-mod"> 5547 <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> 5548 </div> 5549 </div> 5550 </div> 5551 </div> 5552 } 5553 5554 @helper RenderMiniCartModalLayout() 5555 { 5556 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 5557 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage"); 5558 5559 <div class="mini-cart grid__cell dw-mod"> 5560 <input type="checkbox" id="miniCartTrigger" class="modal-trigger" autocomplete="off" /> 5561 <div class="modal-container dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink"> 5562 <label for="miniCartTrigger" class="modal-overlay"></label> 5563 <div class="modal modal--md modal--top-right dw-mod"> 5564 <div class="modal__body u-flex grid--direction-column dw-mod"> 5565 <h3 class="dw-mod u-ta-center">@Translate("Shopping cart")</h3> 5566 <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> 5567 </div> 5568 <label class="modal__close-btn modal__close-btn--clean dw-mod" for="miniCartTrigger" title="@Translate("Close modal")"></label> 5569 </div> 5570 </div> 5571 </div> 5572 } 5573 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5574 5575 @using System 5576 @using System.Web 5577 @using Dynamicweb.Rapido.Blocks.Extensibility 5578 @using Dynamicweb.Rapido.Blocks 5579 5580 @{ 5581 bool showOrderDraftLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOrderDraftIcon"); 5582 5583 Block masterDesktopActionsMenuOrderDraft = new Block 5584 { 5585 Id = "MasterDesktopActionsMenuOrderDraft", 5586 SortId = 40, 5587 Template = RenderOrderDraft() 5588 }; 5589 5590 if (showOrderDraftLink && Model.CurrentUser.ID > 0) 5591 { 5592 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuOrderDraft); 5593 } 5594 } 5595 5596 @helper RenderOrderDraft() 5597 { 5598 int OrderDraftPageId = GetPageIdByNavigationTag("OrderDraft"); 5599 string OrderDraftPageLink = "/Default.aspx?ID=" + OrderDraftPageId; 5600 string draftIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard"; 5601 5602 5603 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5604 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5605 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5606 5607 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5608 <a href="@OrderDraftPageLink" class="@menuLinkClass dw-mod" title="@Translate("My order drafts")"> 5609 <span class="u-inline u-position-relative"> 5610 <i class="@draftIcon fa-1_5x"></i> 5611 </span> 5612 </a> 5613 </li> 5614 } 5615 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5616 5617 @using System 5618 @using System.Web 5619 @using Dynamicweb.Rapido.Blocks.Extensibility 5620 @using Dynamicweb.Rapido.Blocks 5621 5622 @{ 5623 bool showDownloadCartLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart"); 5624 5625 Block masterDesktopActionsMenuDownloadCart = new Block 5626 { 5627 Id = "MasterDesktopActionsMenuDownloadCart", 5628 SortId = 50, 5629 Template = RenderDownloadCart() 5630 }; 5631 5632 if (showDownloadCartLink && Model.CurrentUser.ID > 0) 5633 { 5634 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuDownloadCart); 5635 } 5636 } 5637 5638 @helper RenderDownloadCart() 5639 { 5640 int downloadCartPageId = GetPageIdByNavigationTag("DownloadCart"); 5641 string downloadCartPageLink = "/Default.aspx?ID=" + downloadCartPageId; 5642 5643 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5644 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean"; 5645 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5646 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right"; 5647 5648 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod"> 5649 <a href="@downloadCartPageLink" class="@menuLinkClass dw-mod" title="@Translate("Download cart")"> 5650 <span class="u-inline u-position-relative"> 5651 <i class="fas fa-cart-arrow-down fa-1_5x"></i> 5652 <span class="mini-cart__counter u-hidden @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod js-download-cart-counter"></span> 5653 </span> 5654 </a> 5655 </li> 5656 } 5657 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5658 5659 @using System 5660 @using System.Web 5661 @using Dynamicweb.Rapido.Blocks.Extensibility 5662 @using Dynamicweb.Rapido.Blocks 5663 5664 @functions { 5665 public class SearchConfiguration 5666 { 5667 public string searchFeedId { get; set; } 5668 public string searchSecondFeedId { get; set; } 5669 public int groupsFeedId { get; set; } 5670 public string resultPageLink { get; set; } 5671 public string searchPlaceholder { get; set; } 5672 public string searchType { get; set; } 5673 public string searchTemplate { get; set; } 5674 public string searchContentTemplate { get; set; } 5675 public string searchValue { get; set; } 5676 public bool showGroups { get; set; } 5677 5678 public SearchConfiguration() 5679 { 5680 searchFeedId = ""; 5681 searchSecondFeedId = ""; 5682 searchType = "product-search"; 5683 searchContentTemplate = ""; 5684 showGroups = true; 5685 } 5686 } 5687 } 5688 @{ 5689 Block masterSearchBar = new Block 5690 { 5691 Id = "MasterSearchBar", 5692 SortId = 40, 5693 Template = RenderSearch("bar"), 5694 Design = new Design 5695 { 5696 Size = "auto", 5697 HidePadding = true, 5698 RenderType = RenderType.Column 5699 } 5700 }; 5701 5702 Block masterSearchAction = new Block 5703 { 5704 Id = "MasterDesktopActionsMenuSearch", 5705 SortId = 10, 5706 Template = RenderSearch() 5707 }; 5708 5709 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterSearchBar); 5710 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterSearchAction); 5711 } 5712 5713 @helper RenderSearch(string type = "mini-search") 5714 { 5715 string productsPageId = Converter.ToString(GetPageIdByNavigationTag("ProductsPage")); 5716 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 5717 string searchType = Model.Area.Item.GetItem("Layout").GetList("TopSearch") != null ? Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue : "productSearch"; 5718 5719 SearchConfiguration searchConfiguration = null; 5720 5721 switch (searchType) { 5722 case "contentSearch": 5723 searchConfiguration = new SearchConfiguration() { 5724 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true", 5725 resultPageLink = contentSearchPageLink, 5726 searchPlaceholder = Translate("Search page"), 5727 groupsFeedId = 0, 5728 searchType = "content-search", 5729 searchTemplate = "SearchPagesTemplate", 5730 showGroups = false 5731 }; 5732 break; 5733 case "combinedSearch": 5734 searchConfiguration = new SearchConfiguration() { 5735 searchFeedId = productsPageId + "&feed=true", 5736 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true", 5737 resultPageLink = Converter.ToString(productsPageId), 5738 searchPlaceholder = Translate("Search products or pages"), 5739 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"), 5740 searchType = "combined-search", 5741 searchTemplate = "SearchProductsTemplateWrap", 5742 searchContentTemplate = "SearchPagesTemplateWrap", 5743 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector") 5744 }; 5745 break; 5746 default: //productSearch 5747 searchConfiguration = new SearchConfiguration() { 5748 resultPageLink = Converter.ToString(productsPageId), 5749 searchFeedId = productsPageId + "&feed=true", 5750 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"), 5751 searchPlaceholder = Translate("Search products"), 5752 searchTemplate = "SearchProductsTemplate", 5753 searchType = "product-search", 5754 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector") 5755 }; 5756 break; 5757 } 5758 searchConfiguration.searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 5759 5760 if (type == "mini-search") { 5761 @RenderMiniSearch(searchConfiguration) 5762 } else { 5763 @RenderSearchBar(searchConfiguration) 5764 } 5765 } 5766 5767 @helper RenderSearchBar(SearchConfiguration options) 5768 { 5769 <div class="typeahead typeahead--centered u-color-inherit js-typeahead dw-mod" id="ProductSearchBar" 5770 data-page-size="7" 5771 data-search-feed-id="@options.searchFeedId" 5772 data-search-second-feed-id="@options.searchSecondFeedId" 5773 data-result-page-id="@options.resultPageLink" 5774 data-groups-page-id="@options.groupsFeedId" 5775 data-search-type="@options.searchType"> 5776 @if (options.showGroups) 5777 { 5778 <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> 5779 <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> 5780 } 5781 <div class="typeahead-search-field"> 5782 <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"> 5783 @if (string.IsNullOrEmpty(options.searchSecondFeedId)) 5784 { 5785 <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> 5786 } 5787 else 5788 { 5789 <div class="dropdown dropdown--absolute-position dropdown--combined grid"> 5790 <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> 5791 <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> 5792 </div> 5793 } 5794 </div> 5795 <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> 5796 </div> 5797 } 5798 5799 @helper RenderMiniSearch(SearchConfiguration options) 5800 { 5801 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5802 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon"; 5803 5804 <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"> 5805 <div class="@menuLinkClass dw-mod" title="@Translate("Search")"> 5806 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i> 5807 </div> 5808 <div class="menu menu--dropdown menu--dropdown-right u-no-padding u-w380px grid__cell dw-mod"> 5809 <div class="typeahead js-typeahead" id="ProductSearchBar" 5810 data-page-size="7" 5811 data-search-feed-id="@options.searchFeedId" 5812 data-search-second-feed-id="@options.searchSecondFeedId" 5813 data-result-page-id="@options.resultPageLink" 5814 data-search-type="@options.searchType"> 5815 <div class="typeahead-search-field"> 5816 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" id="headerSearch" placeholder="@options.searchPlaceholder" value="@options.searchValue"> 5817 @if (string.IsNullOrEmpty(options.searchSecondFeedId)) 5818 { 5819 <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> 5820 } 5821 else 5822 { 5823 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--right-aligned"> 5824 <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> 5825 <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> 5826 </div> 5827 } 5828 </div> 5829 </div> 5830 </div> 5831 </li> 5832 } 5833 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 5834 5835 @using System 5836 @using System.Web 5837 @using Dynamicweb.Rapido.Blocks.Extensibility 5838 @using Dynamicweb.Rapido.Blocks 5839 5840 @{ 5841 string headerConfigurationTopLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 5842 bool headerConfigurationHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 5843 5844 BlocksPage headerConfigurationPage = BlocksPage.GetBlockPage("Master"); 5845 5846 Block configDesktopLogo = headerConfigurationPage.GetBlockById("MasterDesktopLogo"); 5847 headerConfigurationPage.RemoveBlock(configDesktopLogo); 5848 5849 Block configDesktopMenu = headerConfigurationPage.GetBlockById("MasterDesktopMenu"); 5850 headerConfigurationPage.RemoveBlock(configDesktopMenu); 5851 5852 Block configSearchBar = headerConfigurationPage.GetBlockById("MasterSearchBar"); 5853 headerConfigurationPage.RemoveBlock(configSearchBar); 5854 5855 Block configSearchAction = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenuSearch"); 5856 headerConfigurationPage.RemoveBlock(configSearchAction); 5857 5858 Block configDesktopActionsMenu = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenu"); 5859 headerConfigurationPage.RemoveBlock(configDesktopActionsMenu); 5860 5861 Block configDesktopExtra = headerConfigurationPage.GetBlockById("MasterDesktopExtra"); 5862 5863 switch (headerConfigurationTopLayout) 5864 { 5865 case "condensed": //2 5866 configDesktopLogo.Design.Size = "auto-width"; 5867 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5868 5869 configDesktopMenu.SortId = 20; 5870 configDesktopMenu.Design.Size = "auto"; 5871 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5872 5873 configDesktopActionsMenu.SortId = 30; 5874 configDesktopActionsMenu.Design.Size = "auto-width"; 5875 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5876 5877 if (!headerConfigurationHideSearch) 5878 { 5879 configSearchBar.SortId = 40; 5880 configSearchBar.Design.Size = "12"; 5881 configDesktopExtra.SortId = 50; 5882 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 5883 } 5884 break; 5885 case "splitted": //3 5886 configDesktopLogo.Design.Size = "auto"; 5887 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5888 5889 if (!headerConfigurationHideSearch) 5890 { 5891 configSearchBar.SortId = 20; 5892 configSearchBar.Design.Size = "auto"; 5893 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 5894 } 5895 5896 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5897 5898 configDesktopActionsMenu.SortId = 20; 5899 configDesktopActionsMenu.Design.Size = "auto-width"; 5900 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5901 break; 5902 case "splitted-center": //4 5903 configDesktopLogo.Design.Size = "auto"; 5904 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5905 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5906 5907 configDesktopActionsMenu.SortId = 30; 5908 configDesktopActionsMenu.Design.Size = "auto-width"; 5909 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu); 5910 5911 if (!headerConfigurationHideSearch) 5912 { 5913 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5914 } 5915 break; 5916 case "minimal": //5 5917 configDesktopLogo.Design.Size = "auto-width"; 5918 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5919 5920 configDesktopMenu.Design.Size = "auto"; 5921 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5922 5923 configDesktopActionsMenu.SortId = 20; 5924 configDesktopActionsMenu.Design.Size = "auto-width"; 5925 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5926 5927 if (!headerConfigurationHideSearch) 5928 { 5929 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5930 } 5931 break; 5932 case "minimal-center": //6 5933 configDesktopLogo.Design.Size = "auto-width"; 5934 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5935 5936 configDesktopMenu.Design.Size = "auto"; 5937 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5938 5939 configDesktopActionsMenu.SortId = 20; 5940 configDesktopActionsMenu.Design.Size = "auto-width"; 5941 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5942 5943 if (!headerConfigurationHideSearch) 5944 { 5945 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5946 } 5947 break; 5948 case "minimal-right": //7 5949 configDesktopLogo.Design.Size = "auto-width"; 5950 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo); 5951 5952 configDesktopMenu.Design.Size = "auto"; 5953 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5954 5955 configDesktopActionsMenu.SortId = 20; 5956 configDesktopActionsMenu.Design.Size = "auto-width"; 5957 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5958 5959 if (!headerConfigurationHideSearch) 5960 { 5961 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5962 } 5963 break; 5964 case "two-lines": //8 5965 configDesktopLogo.Design.Size = "auto"; 5966 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5967 5968 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5969 5970 configDesktopActionsMenu.SortId = 20; 5971 configDesktopActionsMenu.Design.Size = "auto-width"; 5972 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5973 5974 if (!headerConfigurationHideSearch) 5975 { 5976 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5977 } 5978 break; 5979 case "two-lines-centered": //9 5980 configDesktopLogo.Design.Size = "auto"; 5981 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5982 5983 configDesktopMenu.Design.Size = "auto-width"; 5984 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 5985 5986 configDesktopActionsMenu.SortId = 20; 5987 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu); 5988 5989 if (!headerConfigurationHideSearch) 5990 { 5991 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction); 5992 } 5993 break; 5994 case "normal": //1 5995 default: 5996 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo); 5997 5998 if (!headerConfigurationHideSearch) 5999 { 6000 configSearchBar.SortId = 20; 6001 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar); 6002 } 6003 6004 configDesktopActionsMenu.SortId = 30; 6005 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu); 6006 6007 configDesktopActionsMenu.Design.Size = "auto-width"; 6008 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu); 6009 break; 6010 } 6011 } 6012 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6013 6014 @using System 6015 @using System.Web 6016 @using Dynamicweb.Rapido.Blocks.Extensibility 6017 @using Dynamicweb.Rapido.Blocks 6018 6019 6020 6021 6022 6023 @helper RenderDesktopTools() 6024 { 6025 if (Pageview.Area.ID != 24 && Pageview.Area.ID != 25){ 6026 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopTools").OrderBy(item => item.SortId).ToList(); 6027 Dynamicweb.Frontend.PriceViewModel total = Model.Cart.TotalPrice; 6028 double shippingLimit = 1000; 6029 double cartTotal = total != null ? total.PriceWithVat.Value : 0; 6030 double amountToFreeShipping = shippingLimit - cartTotal; 6031 double progressPercentage = Math.Min((cartTotal / shippingLimit) * 100, 100); 6032 var initialPrice = Model.Cart.TotalPrice?.PriceWithVat != null 6033 ? Model.Cart.TotalPrice.PriceWithVat.Value.ToString("N0") + " kr" 6034 : "0 kr"; 6035 6036 <div class="tools-navigation dw-mod"> 6037 <div class="center-container grid top-container__center-container dw-mod" style="display:block;"> 6038 <div style="display:grid; grid-template-rows: 1fr; grid-template-columns: repeat(5, auto); justify-items: start; gap: 1rem;"> 6039 <span ><i class="fas fa-check" style="padding-right: 1rem;"></i>Samme dags forsendelse</span> 6040 <span ><i class="fas fa-check" style="padding-right: 1rem;"></i>Norsk butikk</span> 6041 <span ><i class="fas fa-check" style="padding-right: 1rem;"></i>Fri frakt over 1000,-</span> 6042 <span ><i class="fas fa-check" style="padding-right: 1rem;"></i>Gratis eksperthjelp</span> 6043 6044 <!-- Free Shipping Progress Bar Cell --> 6045 <div class="free-shipping-container" style="display:grid; align-items: baseline; grid-template-columns: 1fr 2fr; gap: 2rem;"> 6046 <span class="FreeshippingPrice" style="font-weight: bold; width: 100%;"> 6047 @if (cartTotal < shippingLimit) 6048 { 6049 @($"{amountToFreeShipping} kr igjen til gratis frakt") 6050 } 6051 else 6052 { 6053 <span>Du har gratis frakt!</span> 6054 } 6055 </span> 6056 6057 <div style="background-color: #e0e0e0; height: 8px; width: 100%; border-radius: 4px; margin-top: 0.5rem;"> 6058 <div class="progress-bar" style="background-color: #ca1c1c; width: @progressPercentage%; height: 100%; border-radius: 4px;"></div> 6059 </div> 6060 </div> 6061 </div> 6062 </div> 6063 </div> 6064 6065 <script> 6066 document.addEventListener('DOMContentLoaded', function () { 6067 // Now `initialPrice` is available directly as a string 6068 let initialPrice = "@initialPrice"; 6069 6070 // Function to initialize or update the free shipping bar 6071 function updateFreeShippingBar(totalPrice) { 6072 const freeShippingText = document.querySelector(".FreeshippingPrice"); 6073 const progressBar = document.querySelector(".progress-bar"); 6074 const shippingLimit = 1000; 6075 6076 if (freeShippingText && progressBar) { 6077 let priceParsed = parseFloat(totalPrice.replace("kr", "").replace(/\s/g, "")); 6078 let amountToFreeShipping = shippingLimit - priceParsed; 6079 let progressPercentage = Math.min((priceParsed / shippingLimit) * 100, 100); 6080 6081 freeShippingText.innerText = priceParsed < shippingLimit 6082 ? `${amountToFreeShipping} kr igjen til gratis frakt` 6083 : "Du har gratis frakt!"; 6084 6085 progressBar.style.width = `${progressPercentage}%`; 6086 } 6087 } 6088 6089 // Initial setup based on cart total at page load 6090 updateFreeShippingBar(initialPrice); 6091 6092 // Listen for cart updates to dynamically update the bar 6093 document.addEventListener('cartUpdated', function (event) { 6094 let updatedPrice = event?.detail?.data[0]?.totalPriceWithVat; 6095 updateFreeShippingBar(updatedPrice); 6096 }); 6097 }); 6098 </script> 6099 } 6100 } 6101 6102 6103 6104 6105 6106 @helper RenderDesktopToolsText() 6107 { 6108 string toolsText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("ToolsText"); 6109 if (!string.IsNullOrEmpty(toolsText)) 6110 { 6111 <div class="u-margin-top u-margin-bottom">@toolsText</div> 6112 } 6113 } 6114 6115 @helper RenderDesktopToolsNavigation() 6116 { 6117 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar"); 6118 6119 if (renderPagesInToolBar) 6120 { 6121 @RenderNavigation(new 6122 { 6123 id = "topToolsNavigation", 6124 cssclass = "menu menu-tools dw-mod dwnavigation", 6125 template = "TopMenu.xslt" 6126 }) 6127 } 6128 } 6129 6130 @helper RenderDesktopNavigation() 6131 { 6132 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopNavigation").OrderBy(item => item.SortId).ToList(); 6133 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal"; 6134 string alignClass = topLayout == "two-lines-centered" ? "grid--justify-center" : ""; 6135 <nav class="main-navigation dw-mod"> 6136 <div class="center-container top-container__center-container grid @alignClass dw-mod"> 6137 @RenderBlockList(subBlocks) 6138 </div> 6139 </nav> 6140 } 6141 6142 @helper RenderDesktopExtra() 6143 { 6144 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopExtra").OrderBy(item => item.SortId).ToList(); 6145 6146 if (subBlocks.Count > 0) 6147 { 6148 <div class="header header-top dw-mod test"> 6149 <div class="center-container top-container__center-container grid--justify-space-between grid grid--align-center dw-mod"> 6150 @RenderBlockList(subBlocks) 6151 </div> 6152 </div> 6153 } 6154 }</text> 6155 } 6156 6157 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6158 6159 @using System 6160 @using System.Web 6161 @using Dynamicweb.Rapido.Blocks.Extensibility 6162 @using Dynamicweb.Rapido.Blocks 6163 @using Dynamicweb.Rapido.Blocks.Components.General 6164 @using Dynamicweb.Frontend 6165 6166 @functions { 6167 int impersonationPageId; 6168 string impersonationLayout; 6169 int impersonationFeed; 6170 Block impersonationBar; 6171 6172 string getUserNameFromParams(string firstName, string middleName, string lastName, string name, string email, string userName) 6173 { 6174 string username = ""; 6175 6176 if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName)) 6177 { 6178 username = firstName + " " + (!string.IsNullOrEmpty(middleName) ? middleName + " " : "") + lastName; 6179 } 6180 else if (!string.IsNullOrEmpty(name)) 6181 { 6182 username = name; 6183 } 6184 else if (!string.IsNullOrEmpty(email)) 6185 { 6186 username = email; 6187 } 6188 else 6189 { 6190 username = userName; 6191 } 6192 return username; 6193 } 6194 6195 string getUserName(UserViewModel user) 6196 { 6197 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName); 6198 } 6199 6200 string getUserName(Dynamicweb.Security.UserManagement.User user) 6201 { 6202 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName); 6203 } 6204 } 6205 6206 @{ 6207 impersonationPageId = GetPageIdByNavigationTag("Impersonation"); 6208 impersonationLayout = Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout") != null ? Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout").SelectedValue : "bar"; 6209 impersonationFeed = GetPageIdByNavigationTag("UsersFeed"); 6210 6211 if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0) 6212 { 6213 impersonationBar = new Block 6214 { 6215 Id = "ImpersonationBar", 6216 SortId = 50, 6217 Template = RenderImpersonation(), 6218 SkipRenderBlocksList = true, 6219 Design = new Design 6220 { 6221 Size = "auto-width", 6222 HidePadding = true, 6223 RenderType = RenderType.Column 6224 } 6225 }; 6226 6227 if (impersonationLayout == "top-bar") { 6228 impersonationBar.SortId = 9; 6229 } 6230 6231 Block impersonationContent = new Block 6232 { 6233 Id = "ImpersonationContent", 6234 SortId = 20 6235 }; 6236 6237 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0) 6238 { 6239 //Render stop impersonation view 6240 impersonationContent.Template = RenderStopImpersonationView(); 6241 6242 6243 Modal stopImpersonation = new Modal 6244 { 6245 Id = "StopImpersonation", 6246 Heading = new Heading { 6247 Level = 2, 6248 Title = Translate("Sign out"), 6249 Icon = new Icon { 6250 Name = "fa-sign-out", 6251 Prefix = "fas", 6252 LabelPosition = IconLabelPosition.After 6253 } 6254 }, 6255 Width = ModalWidth.Sm, 6256 BodyTemplate = RenderStopImpersonationForm() 6257 }; 6258 6259 Block stopImpersonationBlock = new Block 6260 { 6261 Id = "StopImpersonationBlock", 6262 SortId = 10, 6263 Component = stopImpersonation 6264 }; 6265 impersonationBar.BlocksList.Add(stopImpersonationBlock); 6266 } 6267 else 6268 { 6269 //Render main view 6270 switch (impersonationLayout) 6271 { 6272 case "right-lower-box": 6273 impersonationContent.BlocksList.Add( 6274 new Block { 6275 Id = "RightLowerBoxHeader", 6276 SortId = 10, 6277 Component = new Heading { 6278 Level = 5, 6279 Title = Translate("View the list of users you can sign in as"), 6280 CssClass = "impersonation-text" 6281 } 6282 } 6283 ); 6284 impersonationContent.BlocksList.Add( 6285 new Block { 6286 Id = "RightLowerBoxContent", 6287 SortId = 20, 6288 Template = RenderImpersonationControls() 6289 } 6290 ); 6291 break; 6292 case "right-lower-bar": 6293 impersonationContent.BlocksList.Add( 6294 new Block { 6295 Id = "RightLowerBarContent", 6296 SortId = 10, 6297 Template = RenderImpersonationControls() 6298 } 6299 ); 6300 break; 6301 case "bar": 6302 default: 6303 impersonationContent.BlocksList.Add( 6304 new Block { 6305 Id = "ViewListLink", 6306 SortId = 20, 6307 Template = RenderViewListLink() 6308 } 6309 ); 6310 impersonationContent.BlocksList.Add( 6311 new Block { 6312 Id = "BarTypeaheadSearch", 6313 SortId = 30, 6314 Template = RenderTypeaheadSearch() 6315 } 6316 ); 6317 break; 6318 } 6319 } 6320 impersonationBar.BlocksList.Add(impersonationContent); 6321 6322 impersonationBar.BlocksList.Add( 6323 new Block 6324 { 6325 Id = "ImpersonationSearchTemplates", 6326 SortId = 30, 6327 Template = RenderSearchResultTemplate() 6328 } 6329 ); 6330 if (impersonationLayout != "bar" && impersonationLayout != "top-bar") 6331 { 6332 impersonationBar.BlocksList.Add( 6333 new Block 6334 { 6335 Id = "ImpersonationSearchScripts", 6336 SortId = 40, 6337 Template = RenderSearchScripts() 6338 } 6339 ); 6340 } 6341 BlocksPage.GetBlockPage("Master").Add("MasterHeader", impersonationBar); 6342 } 6343 } 6344 6345 @helper RenderImpersonation() 6346 { 6347 List<Block> subBlocks = impersonationBar.BlocksList.OrderBy(item => item.SortId).ToList(); 6348 <input type="checkbox" class="impersonation-trigger js-remember-state" id="ImpersonationMinimizeTrigger" /> 6349 <div class="impersonation impersonation--@(impersonationLayout)-layout dw-mod" id="Impersonation"> 6350 @if (impersonationLayout == "right-lower-box") 6351 { 6352 @RenderRightLowerBoxHeader() 6353 } 6354 <div class="center-container top-container__center-container impersonation__container @(impersonationLayout != "bar" && impersonationLayout != "top-bar" ? "impersonation__container--box" : "") dw-mod"> 6355 @*Impersonation*@ 6356 @RenderBlockList(subBlocks) 6357 </div> 6358 </div> 6359 } 6360 6361 @helper RenderRightLowerBoxHeader() 6362 { 6363 <div class="impersonation__header dw-mod"> 6364 <div class="impersonation__title">@Translate("Impersonation")</div> 6365 <label for="ImpersonationMinimizeTrigger" class="btn btn--impersonation impersonation__minimize-btn dw-mod" onclick="this.blur();"> 6366 @Render(new Icon 6367 { 6368 Prefix = "fas", 6369 Name = "fa-window-minimize" 6370 }) 6371 </label> 6372 </div> 6373 } 6374 6375 @helper RenderStopImpersonationView() 6376 { 6377 string secondaryUserName = getUserName(Model.CurrentSecondaryUser); 6378 string userName = getUserName(Pageview.User); 6379 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> "; 6380 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; 6381 6382 if (impersonationLayout == "right-lower-box") 6383 { 6384 <div class="u-margin-bottom--lg u-ta-center"> 6385 @impersonationText 6386 </div> 6387 <div class="u-margin-bottom--lg u-ta-center"> 6388 @RenderSwitchAccountButton() 6389 </div> 6390 @RenderStopImpersonationButton() 6391 } 6392 else 6393 { 6394 <div class="grid grid--align-center impersonation__stop-wrap"> 6395 <div class="impersonation-bar-item dw-mod"> 6396 @impersonationText 6397 </div> 6398 <div class="impersonation-bar-item dw-mod"> 6399 @RenderSwitchAccountButton() 6400 </div> 6401 <div class="impersonation-bar-item dw-mod"> 6402 @RenderStopImpersonationButton() 6403 </div> 6404 </div> 6405 } 6406 } 6407 6408 @helper RenderSwitchAccountButton() { 6409 @Render(new Button 6410 { 6411 Href = "/Default.aspx?ID=" + impersonationPageId, 6412 ButtonType = ButtonType.Button, 6413 ButtonLayout = ButtonLayout.Clean, 6414 Title = Translate("Switch account"), 6415 Icon = new Icon { 6416 Name = "fa-users", 6417 Prefix = "fal", 6418 LabelPosition = IconLabelPosition.After 6419 }, 6420 CssClass = "u-no-margin u-color-inherit" 6421 }) 6422 } 6423 6424 @helper RenderStopImpersonationForm() 6425 { 6426 string secondaryUserName = getUserName(Model.CurrentSecondaryUser); 6427 string userName = getUserName(Pageview.User); 6428 int pageId = Model.TopPage.ID; 6429 6430 <form method="post" class="u-no-margin"> 6431 @Render(new Button 6432 { 6433 ButtonType = ButtonType.Submit, 6434 ButtonLayout = ButtonLayout.Secondary, 6435 Title = Translate("Sign out as") + " " + userName, 6436 Href = "/Default.aspx?ID=" + impersonationPageId, 6437 CssClass = "btn--full", 6438 Name = "DwExtranetRemoveSecondaryUser" 6439 }) 6440 6441 @Render(new Button 6442 { 6443 ButtonType = ButtonType.Submit, 6444 ButtonLayout = ButtonLayout.Secondary, 6445 Title = Translate("Sign out as") + " " + secondaryUserName, 6446 Href = "/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, 6447 CssClass = "btn--full", 6448 Name = "DwExtranetRemoveSecondaryUser" 6449 }) 6450 </form> 6451 } 6452 6453 @helper RenderStopImpersonationButton() { 6454 @Render(new Button 6455 { 6456 ButtonType = ButtonType.Button, 6457 ButtonLayout = ButtonLayout.Clean, 6458 Title = Translate("Sign out"), 6459 Icon = new Icon { 6460 Name = "fa-sign-out", 6461 Prefix = "fal", 6462 LabelPosition = IconLabelPosition.After 6463 }, 6464 OnClick = "document.getElementById('StopImpersonationModalTrigger').checked = true", 6465 CssClass = "u-no-margin" 6466 }) 6467 } 6468 6469 @helper RenderImpersonationControls() 6470 { 6471 <div class="impersonation__controls"> 6472 @RenderViewListLink() 6473 @RenderSearchBox() 6474 </div> 6475 @RenderResultsList() 6476 } 6477 6478 @helper RenderViewListLink() 6479 { 6480 string title = impersonationLayout == "right-lower-box" ? Translate("View the list") : Translate("View the list of users you can sign in as"); 6481 string buttonClasses = impersonationLayout == "right-lower-box" ? "impersonation__button btn btn--impersonation" : "impersonation__link impersonation__link"; 6482 6483 @Render(new Link { 6484 ButtonLayout = ButtonLayout.None, 6485 Title = title, 6486 Href = "/Default.aspx?ID=" + impersonationPageId, 6487 CssClass = buttonClasses 6488 }) 6489 } 6490 6491 @helper RenderSearchBox() 6492 { 6493 <div class="impersonation__search-wrap"> 6494 <input placeholder="@Translate("Search users")" type="text" class="impersonation__search-field dw-mod" onkeyup="searchKeyUpHandler(event)" id="ImpersonationBoxSearchField"> 6495 <div id="ImpersonationBoxSearchFind" class="impersonation__search-icon dw-mod" onclick="updateResults(document.getElementById('ImpersonationBoxSearchField').value)"> 6496 <i class="fal fa-search"></i> 6497 </div> 6498 <div id="ImpersonationBoxSearchClear" class="impersonation__search-icon u-hidden dw-mod" onclick="clearResults();"> 6499 <i class="fal fa-times"></i> 6500 </div> 6501 </div> 6502 } 6503 6504 @helper RenderTypeaheadSearch() 6505 { 6506 <div class="typeahead u-ta-right impersonation__typeahead js-typeahead dw-mod" id="ImpersonationSearchBar" 6507 data-page-size="5" 6508 data-search-feed-id="@impersonationFeed" 6509 data-result-page-id="@impersonationPageId" 6510 data-search-type="user-search" 6511 data-search-parameter-name="q"> 6512 6513 <div class="typeahead-search-field"> 6514 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" placeholder="@Translate("Search users")"> 6515 <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> 6516 </div> 6517 </div> 6518 } 6519 6520 @helper RenderResultsList() 6521 { 6522 <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> 6523 } 6524 6525 @helper RenderSearchResultTemplate() 6526 { 6527 <script id="ImpersonationSearchResult" type="text/x-template"> 6528 {{#.}} 6529 {{#Users}} 6530 <li class="impersonation__search-results-item impersonation-user"> 6531 <form method="post" class="impersonation-user__form" name="account{{id}}"> 6532 <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" value="{{id}}"> 6533 <div class="impersonation-user__info"> 6534 <div class="impersonation-user__name">{{userName}}</div> 6535 <div class="impersonation-user__number">{{customerNumber}}</div> 6536 </div> 6537 @Render(new Button 6538 { 6539 ButtonType = ButtonType.Submit, 6540 ButtonLayout = ButtonLayout.Secondary, 6541 Title = Translate("Sign in as"), 6542 CssClass = "impersonation-user__sign-in-btn" + (impersonationLayout != "bar" ? " btn--impersonation" : "") 6543 }) 6544 </form> 6545 </li> 6546 {{/Users}} 6547 {{#unless Users}} 6548 <li class="impersonation__search-results-item impersonation__search-results-item--not-found"> 6549 @Translate("Your search gave 0 results") 6550 </li> 6551 {{/unless}} 6552 {{/.}} 6553 </script> 6554 } 6555 6556 @helper RenderSearchScripts() 6557 { 6558 <script> 6559 let inputDelayTimer; 6560 function searchKeyUpHandler(e) { 6561 clearTimeout(inputDelayTimer); 6562 let value = e.target.value; 6563 if (value != "") { 6564 inputDelayTimer = setTimeout(function () { 6565 updateResults(value); 6566 }, 500); 6567 } else { 6568 clearResults(); 6569 } 6570 }; 6571 6572 function updateResults(value) { 6573 if (value == "") { 6574 return null; 6575 } 6576 HandlebarsBolt.UpdateContent("ImpersonationBoxSearchResults", "/Default.aspx?ID=@impersonationFeed&q=" + value); 6577 document.getElementById("ImpersonationBoxSearchFind").classList.add("u-hidden"); 6578 document.getElementById("ImpersonationBoxSearchClear").classList.remove("u-hidden"); 6579 } 6580 6581 function clearResults() { 6582 document.getElementById("ImpersonationBoxSearchField").value = ""; 6583 HandlebarsBolt.CleanContainer("ImpersonationBoxSearchResults"); 6584 document.getElementById("ImpersonationBoxSearchFind").classList.remove("u-hidden"); 6585 document.getElementById("ImpersonationBoxSearchClear").classList.add("u-hidden"); 6586 } 6587 </script> 6588 } 6589 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6590 6591 @using System 6592 @using System.Web 6593 @using System.Collections.Generic 6594 @using Dynamicweb.Rapido.Blocks.Extensibility 6595 @using Dynamicweb.Rapido.Blocks 6596 6597 @{ 6598 BlocksPage miniCartBlocksPage = BlocksPage.GetBlockPage("Master"); 6599 string orderlinesView = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView").SelectedValue : "table"; 6600 6601 Block orderLines = new Block 6602 { 6603 Id = "MiniCartOrderLines", 6604 SkipRenderBlocksList = true, 6605 BlocksList = new List<Block> 6606 { 6607 new Block { 6608 Id = "MiniCartOrderLinesList", 6609 SortId = 20, 6610 Template = RenderMiniCartOrderLinesList() 6611 } 6612 } 6613 }; 6614 6615 Block orderlinesScriptTemplates = new Block 6616 { 6617 Id = "OrderlinesScriptTemplates" 6618 }; 6619 6620 if (orderlinesView == "table") 6621 { 6622 orderLines.Template = RenderMiniCartOrderLinesTable(); 6623 orderLines.BlocksList.Add( 6624 new Block 6625 { 6626 Id = "MiniCartOrderlinesTableHeader", 6627 SortId = 10, 6628 Template = RenderMiniCartOrderLinesHeader() 6629 } 6630 ); 6631 6632 orderlinesScriptTemplates.Template = RenderMiniCartScriptsTableTemplates(); 6633 } 6634 else 6635 { 6636 orderLines.Template = RenderMiniCartOrderLinesBlocks(); 6637 orderlinesScriptTemplates.Template = RenderMiniCartScriptsListTemplates(); 6638 } 6639 6640 miniCartBlocksPage.Add("MasterBottomSnippets", orderlinesScriptTemplates); 6641 6642 Block miniCartScriptTemplates = new Block() 6643 { 6644 Id = "MasterMiniCartTemplates", 6645 SortId = 1, 6646 Template = RenderMiniCartScriptTemplates(), 6647 SkipRenderBlocksList = true, 6648 BlocksList = new List<Block> 6649 { 6650 orderLines, 6651 new Block { 6652 Id = "MiniCartFooter", 6653 Template = RenderMiniCartFooter(), 6654 SortId = 50, 6655 SkipRenderBlocksList = true, 6656 BlocksList = new List<Block> 6657 { 6658 new Block { 6659 Id = "MiniCartSubTotal", 6660 Template = RenderMiniCartSubTotal(), 6661 SortId = 30 6662 }, 6663 new Block { 6664 Id = "MiniCartFees", 6665 Template = RenderMiniCartFees(), 6666 SortId = 40 6667 }, 6668 new Block { 6669 Id = "MiniCartPoints", 6670 Template = RenderMiniCartPoints(), 6671 SortId = 50 6672 }, 6673 new Block { 6674 Id = "MiniCartTotal", 6675 Template = RenderMiniCartTotal(), 6676 SortId = 60 6677 }, 6678 new Block { 6679 Id = "MiniCartDisclaimer", 6680 Template = RenderMiniCartDisclaimer(), 6681 SortId = 70 6682 }, 6683 new Block { 6684 Id = "MiniCartActions", 6685 Template = RenderMiniCartActions(), 6686 SortId = 80 6687 } 6688 } 6689 } 6690 } 6691 }; 6692 6693 miniCartBlocksPage.Add("MasterBottomSnippets", miniCartScriptTemplates); 6694 } 6695 6696 @helper RenderMiniCartScriptsTableTemplates() 6697 { 6698 <script id="MiniCartOrderline" type="text/x-template"> 6699 {{#unless isEmpty}} 6700 <tr> 6701 <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> 6702 <td class="u-va-middle"> 6703 <a href="{{link}}" class="mini-cart-orderline__name" title="{{name}}">{{name}}</a> 6704 {{#if variantname}} 6705 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{variantname}}</a> 6706 {{/if}} 6707 {{#if unitname}} 6708 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{unitname}}</div> 6709 {{/if}} 6710 </td> 6711 <td class="u-ta-right u-va-middle">{{quantity}}</td> 6712 <td class="u-ta-right u-va-middle"> 6713 {{#if pointsTotal}} 6714 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 6715 {{else}} 6716 {{totalprice}} 6717 {{/if}} 6718 </td> 6719 </tr> 6720 {{/unless}} 6721 </script> 6722 6723 <script id="MiniCartOrderlineDiscount" type="text/x-template"> 6724 {{#unless isEmpty}} 6725 <tr class="table__row--no-border"> 6726 <td class="u-w60px">&nbsp;</td> 6727 <td><div class="mini-cart-orderline__name dw-mod">{{name}}</div></td> 6728 <td class="u-ta-right">&nbsp;</td> 6729 <td class="u-ta-right">{{totalprice}}</td> 6730 </tr> 6731 {{/unless}} 6732 </script> 6733 } 6734 6735 @helper RenderMiniCartScriptsListTemplates() 6736 { 6737 int cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 6738 6739 <script id="MiniCartOrderline" type="text/x-template"> 6740 {{#unless isEmpty}} 6741 <div class="mini-cart-orderline grid dw-mod"> 6742 <div class="grid__col-4"> 6743 <a href="{{link}}" class="{{hideimage}}"> 6744 <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}}"> 6745 </a> 6746 </div> 6747 <div class="grid__col-8"> 6748 <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> 6749 {{#if variantname}} 6750 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Variant"): {{variantname}}</div> 6751 {{/if}} 6752 {{#if unitname}} 6753 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Unit"): {{unitname}}</div> 6754 {{/if}} 6755 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Qty"): {{quantity}}</div> 6756 6757 <div class="grid__cell-footer"> 6758 <div class="grid__cell"> 6759 <div class="u-pull--left mini-cart-orderline__price dw-mod"> 6760 {{#if pointsTotal}} 6761 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 6762 {{else}} 6763 {{totalprice}} 6764 {{/if}} 6765 </div> 6766 <button type="button" 6767 title="@Translate("Remove orderline")" 6768 class="btn btn--clean btn--condensed u-pull--right mini-cart-orderline__remove-btn dw-mod" 6769 onclick="{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}}Cart.UpdateCart('miniCartContent', '/Default.aspx?ID=@cartFeedPageId', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);">@Translate("Remove")</button> 6770 </div> 6771 </div> 6772 </div> 6773 </div> 6774 {{/unless}} 6775 </script> 6776 6777 <script id="MiniCartOrderlineDiscount" type="text/x-template"> 6778 {{#unless isEmpty}} 6779 <div class="mini-cart-orderline mini-cart-orderline--discount grid dw-mod"> 6780 <div class="grid__col-4"> 6781 <div class="mini-cart-orderline__name mini-cart-orderline__name dw-mod">{{name}}</div> 6782 </div> 6783 <div class="grid__col-8">{{totalprice}}</div> 6784 </div> 6785 {{/unless}} 6786 </script> 6787 } 6788 6789 @helper RenderMiniCartScriptTemplates() 6790 { 6791 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMiniCartTemplates").OrderBy(item => item.SortId).ToList(); 6792 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 6793 string cartPageLink = string.Concat("/Default.aspx?ID=", GetPageIdByNavigationTag("CartPage")); 6794 bool miniCartUseGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 6795 6796 <script id="MiniCartContent" type="text/x-template"> 6797 {{#.}} 6798 {{#unless isEmpty}} 6799 @if (miniCartUseGoogleTagManager) 6800 { 6801 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 6802 } 6803 @RenderBlockList(subBlocks) 6804 {{/unless}} 6805 {{/.}} 6806 </script> 6807 } 6808 6809 @helper RenderMiniCartOrderLinesTable() 6810 { 6811 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList(); 6812 6813 <div class="u-overflow-auto"> 6814 <table class="table mini-cart-table dw-mod"> 6815 @RenderBlockList(subBlocks) 6816 </table> 6817 </div> 6818 } 6819 6820 @helper RenderMiniCartOrderLinesBlocks() 6821 { 6822 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList(); 6823 6824 <div class="u-overflow-auto"> 6825 @RenderBlockList(subBlocks) 6826 </div> 6827 } 6828 6829 @helper RenderMiniCartOrderLinesHeader() 6830 { 6831 <thead> 6832 <tr> 6833 <td>&nbsp;</td> 6834 <td>@Translate("Product")</td> 6835 <td class="u-ta-right">@Translate("Qty")</td> 6836 <td class="u-ta-right" width="120">@Translate("Price")</td> 6837 </tr> 6838 </thead> 6839 } 6840 6841 @helper RenderMiniCartOrderLinesList() 6842 { 6843 <text> 6844 {{#OrderLines}} 6845 {{#ifCond template "===" "CartOrderline"}} 6846 {{>MiniCartOrderline}} 6847 {{/ifCond}} 6848 {{#ifCond template "===" "CartOrderlineMobile"}} 6849 {{>MiniCartOrderline}} 6850 {{/ifCond}} 6851 {{#ifCond template "===" "CartOrderlineDiscount"}} 6852 {{>MiniCartOrderlineDiscount}} 6853 {{/ifCond}} 6854 {{/OrderLines}} 6855 </text> 6856 } 6857 6858 @helper RenderMiniCartFees() 6859 { 6860 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6861 if (!pointShop) 6862 { 6863 <text> 6864 {{#unless hidePaymentfee}} 6865 <div class="grid"> 6866 <div class="grid__col-6 grid__col--bleed-y"> 6867 {{paymentmethod}} 6868 </div> 6869 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{paymentfee}}</div> 6870 </div> 6871 {{/unless}} 6872 </text> 6873 } 6874 <text> 6875 {{#unless hideShippingfee}} 6876 <div class="grid"> 6877 <div class="grid__col-6 grid__col--bleed-y"> 6878 {{shippingmethod}} 6879 </div> 6880 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{shippingfee}}</div> 6881 </div> 6882 {{/unless}} 6883 </text> 6884 <text> 6885 {{#if hasTaxSettings}} 6886 <div class="grid"> 6887 <div class="grid__col-6 grid__col--bleed-y">@Translate("Sales Tax")</div> 6888 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{totaltaxes}}</div> 6889 </div> 6890 {{/if}} 6891 </text> 6892 } 6893 6894 @helper RenderMiniCartFooter() 6895 { 6896 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartFooter").OrderBy(item => item.SortId).ToList(); 6897 6898 <div class="mini-cart__footer u-border-top u-padding-top dw-mod"> 6899 @RenderBlockList(subBlocks) 6900 </div> 6901 } 6902 6903 @helper RenderMiniCartActions() 6904 { 6905 int cartPageId = GetPageIdByNavigationTag("CartPage"); 6906 6907 <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> 6908 <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> 6909 } 6910 6911 @helper RenderMiniCartPoints() 6912 { 6913 <text> 6914 {{#if earnings}} 6915 <div class="grid"> 6916 <div class="grid__col-6 grid__col--bleed-y">@Translate("Earnings")</div> 6917 <div class="grid__col-6 grid__col--bleed-y grid--align-end"> 6918 <div> 6919 <span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points") 6920 </div> 6921 </div> 6922 </div> 6923 {{/if}} 6924 </text> 6925 } 6926 6927 @helper RenderMiniCartSubTotal() 6928 { 6929 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(Model.Cart.ID); 6930 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6931 if (!pointShop) 6932 { 6933 <text> 6934 {{#unless hideSubTotal}} 6935 <div class="grid dw-mod u-bold"> 6936 <div class="grid__col-6 grid__col--bleed-y">@Translate("Subtotal")</div> 6937 <div class="grid__col-6 grid__col--bleed-y grid--align-end"> 6938 @if (hasTaxSettings) 6939 { 6940 <text>{{subtotalpricewithouttaxes}}</text> 6941 } 6942 else 6943 { 6944 <text>{{subtotalprice}}</text> 6945 } 6946 </div> 6947 </div> 6948 {{/unless}} 6949 </text> 6950 } 6951 } 6952 6953 @helper RenderMiniCartTotal() 6954 { 6955 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 6956 6957 <div class="mini-cart-totals grid u-border-top u-margin-top dw-mod"> 6958 <div class="grid__col-6">@Translate("Total")</div> 6959 <div class="grid__col-6 grid--align-end"> 6960 <div> 6961 @if (pointShop) 6962 { 6963 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 6964 } 6965 else 6966 { 6967 <text>{{totalprice}}</text> 6968 } 6969 </div> 6970 </div> 6971 </div> 6972 } 6973 6974 @helper RenderMiniCartDisclaimer() 6975 { 6976 <text> 6977 {{#if showCheckoutDisclaimer}} 6978 <div class="grid u-margin-bottom u-ta-right"> 6979 <small class="grid__col-12">{{checkoutDisclaimer}}</small> 6980 </div> 6981 {{/if}} 6982 </text> 6983 } 6984 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 6985 6986 @using Dynamicweb.Rapido.Blocks.Extensibility 6987 @using Dynamicweb.Rapido.Blocks 6988 @using Dynamicweb.Rapido.Blocks.Components.General 6989 @using Dynamicweb.Rapido.Blocks.Components 6990 @using Dynamicweb.Rapido.Services 6991 6992 @{ 6993 string addToCartNotificationType = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType").SelectedValue : ""; 6994 string addToCartNotificationMiniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown"; 6995 bool addToCartHideCartIcon = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart"); 6996 6997 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !string.IsNullOrEmpty(addToCartNotificationType)) 6998 { 6999 if (addToCartNotificationType == "modal") 7000 { 7001 Block addToCartNotificationModal = new Block 7002 { 7003 Id = "AddToCartNotificationModal", 7004 Template = RenderAddToCartNotificationModal() 7005 }; 7006 7007 Block addToCartNotificationScript = new Block 7008 { 7009 Id = "AddToCartNotificationScript", 7010 Template = RenderAddToCartNotificationModalScript() 7011 }; 7012 BlocksPage.GetBlockPage("Master").Add("MasterTopSnippets", addToCartNotificationModal); 7013 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript); 7014 } 7015 else if (addToCartNotificationType == "toggle" && addToCartNotificationMiniCartLayout != "none" && !addToCartHideCartIcon && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 7016 { 7017 Block addToCartNotificationScript = new Block 7018 { 7019 Id = "AddToCartNotificationScript", 7020 Template = RenderAddToCartNotificationToggleScript() 7021 }; 7022 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript); 7023 } 7024 } 7025 } 7026 7027 @helper RenderAddToCartNotificationModal() 7028 { 7029 <div id="LastAddedProductModal" data-template="LastAddedProductTemplate"></div> 7030 } 7031 7032 @helper RenderAddToCartNotificationModalScript() 7033 { 7034 int cartPageId = GetPageIdByNavigationTag("CartPage"); 7035 7036 <script id="LastAddedProductTemplate" type="text/x-template"> 7037 @{ 7038 7039 Modal lastAddedProduct = new Modal 7040 { 7041 Id = "LastAddedProduct", 7042 Heading = new Heading 7043 { 7044 Level = 2, 7045 Title = Translate("Product is added to the cart") 7046 }, 7047 Width = ModalWidth.Lg, 7048 BodyTemplate = RenderModalContent() 7049 }; 7050 7051 lastAddedProduct.AddActions( 7052 new Button 7053 { 7054 ButtonType = ButtonType.Button, 7055 ButtonLayout = ButtonLayout.Secondary, 7056 Title = Translate("Continue shopping"), 7057 CssClass = "u-pull--left u-no-margin btn--sm", 7058 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false" 7059 }, 7060 new Link 7061 { 7062 Href = "/Default.aspx?ID=" + cartPageId, 7063 ButtonLayout = ButtonLayout.Secondary, 7064 CssClass = "u-pull--right u-no-margin btn--sm", 7065 Title = Translate("Proceed to checkout"), 7066 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false" 7067 } 7068 ); 7069 7070 @Render(lastAddedProduct) 7071 } 7072 </script> 7073 <script> 7074 document.addEventListener('addToCart', function (event) { 7075 Cart.ShowLastAddedProductModal(event.detail); 7076 }); 7077 </script> 7078 } 7079 7080 @helper RenderModalContent() 7081 { 7082 if (Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile) 7083 { 7084 <div class="grid"> 7085 <div class="grid__col-3"> 7086 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true }) 7087 </div> 7088 <div class="u-padding grid--align-self-center"> 7089 <span>{{quantity}}</span> x 7090 </div> 7091 <div class="grid__col-auto grid--align-self-center"> 7092 <div>{{productInfo.name}}</div> 7093 {{#if productInfo.variantName}} 7094 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small> 7095 {{/if}} 7096 {{#if productInfo.unitName}} 7097 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small> 7098 {{/if}} 7099 </div> 7100 <div class="grid" style="border-top: 2px solid #141b1f;"> 7101 <div class="grid__col-12"> 7102 {{#each productInfo.related}} 7103 <h6 class="u-margin">{{name}}</h6> 7104 <div class="grid" style="column-gap: 6px; row-gap: 6px;"> 7105 {{#each Products}} 7106 <div class="grid grid__col-12 u-padding u-ta-center" style="background-color: #f9fafb;"> 7107 <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> 7108 <div>{{name}}</div> 7109 <div class="item-number dw-mod">{{number}}</div> 7110 <div class="price price--product-page dw-mod">{{price}}</div> 7111 <a class="btn--sm btn btn--secondary dw-mod" href="{{link}}">se mer</a> 7112 7113 <button 7114 id='' 7115 class="btn--sm btn btn--secondary dw-mod" 7116 onclick="Cart.AddToCart(event, { id: '{{number}}',variantId: '',unitId: '',productInfo: {'price':'{{price}}', 'image':'{{image}}', 'name': '{{name}}'},quantity: 1 })" 7117 title="@Translate("Legg til")"><i class="fa fa-shopping-cart"></i></button> 7118 </div> 7119 {{/each}} 7120 </div> 7121 {{/each}} 7122 </div> 7123 </div> 7124 </div> 7125 7126 } 7127 else 7128 { 7129 7130 <div class="grid"> 7131 <div class="grid__col-1"> 7132 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true }) 7133 </div> 7134 <div class="u-padding grid--align-self-center"> 7135 <span>{{quantity}}</span> x 7136 </div> 7137 <div class="grid__col-auto grid--align-self-center"> 7138 <div>{{productInfo.name}}</div> 7139 {{#if productInfo.variantName}} 7140 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small> 7141 {{/if}} 7142 {{#if productInfo.unitName}} 7143 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small> 7144 {{/if}} 7145 </div> 7146 <div class="grid" style="border-top: 2px solid #141b1f;"> 7147 <div class="grid__col-12"> 7148 {{#each productInfo.related}} 7149 <h6 class="u-margin">{{name}}</h6> 7150 <div class="grid" style="column-gap: 6px; row-gap: 6px;"> 7151 {{#each Products}} 7152 <div class="grid grid__col-auto u-padding u-ta-center" style="background-color: #f9fafb;"> 7153 <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> 7154 <div>{{name}}</div> 7155 <div class="item-number dw-mod">{{number}}</div> 7156 <div class="price price--product-page dw-mod">{{price}}</div> 7157 <a class="btn--sm btn btn--secondary dw-mod" href="{{link}}">se mer</a> 7158 7159 <button 7160 id='' 7161 class="btn--sm btn btn--secondary dw-mod" 7162 onclick="Cart.AddToCart(event, { id: '{{number}}',variantId: '',unitId: '',productInfo: {'price':'{{price}}', 'image':'{{image}}', 'name': '{{name}}'},quantity: 1 })" 7163 title="@Translate("Legg til")"><i class="fa fa-shopping-cart"></i></button> 7164 </div> 7165 {{/each}} 7166 </div> 7167 {{/each}} 7168 </div> 7169 </div> 7170 </div> 7171 } 7172 } 7173 7174 7175 @helper RenderAddToCartNotificationToggleScript() 7176 { 7177 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 7178 7179 <script> 7180 document.addEventListener('addToCart', function () { 7181 Cart.ToggleMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '@miniCartFeedPageId'); 7182 }); 7183 </script> 7184 } 7185 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 7186 7187 @using System 7188 @using System.Web 7189 @using System.Collections.Generic 7190 @using Dynamicweb.Rapido.Blocks.Extensibility 7191 @using Dynamicweb.Rapido.Blocks 7192 @using Dynamicweb.Rapido.Blocks.Components.General 7193 7194 @functions { 7195 BlocksPage footerBlocksPage = BlocksPage.GetBlockPage("Master"); 7196 } 7197 7198 @{ 7199 string footerColumnOneContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Content"); 7200 string footerColumnTwoContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Content"); 7201 string footerColumnThreeContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Content"); 7202 string footerColumnOneHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Header"); 7203 string footerColumnTwoHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Header"); 7204 string footerColumnThreeHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Header"); 7205 7206 Block masterFooterContent = new Block() 7207 { 7208 Id = "MasterFooterContent", 7209 SortId = 10, 7210 Template = RenderFooter(), 7211 SkipRenderBlocksList = true 7212 }; 7213 footerBlocksPage.Add(MasterBlockId.MasterFooter, masterFooterContent); 7214 7215 if (!string.IsNullOrEmpty(footerColumnOneContent) || !string.IsNullOrEmpty(footerColumnOneHeader)) 7216 { 7217 Block masterFooterColumnOne = new Block 7218 { 7219 Id = "MasterFooterColumnOne", 7220 SortId = 10, 7221 Template = RenderFooterColumn(footerColumnOneHeader, footerColumnOneContent), 7222 Design = new Design 7223 { 7224 Size = "auto", 7225 RenderType = RenderType.Column 7226 } 7227 }; 7228 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnOne); 7229 } 7230 7231 if (!string.IsNullOrEmpty(footerColumnTwoContent) || !string.IsNullOrEmpty(footerColumnTwoHeader)) 7232 { 7233 Block masterFooterColumnTwo = new Block 7234 { 7235 Id = "MasterFooterColumnTwo", 7236 SortId = 20, 7237 Template = RenderFooterColumn(footerColumnTwoHeader, footerColumnTwoContent), 7238 Design = new Design 7239 { 7240 Size = "auto", 7241 RenderType = RenderType.Column 7242 } 7243 }; 7244 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnTwo); 7245 } 7246 7247 if (!string.IsNullOrEmpty(footerColumnThreeContent) || !string.IsNullOrEmpty(footerColumnThreeHeader)) 7248 { 7249 Block masterFooterColumnThree = new Block 7250 { 7251 Id = "MasterFooterColumnThree", 7252 SortId = 30, 7253 Template = RenderFooterColumn(footerColumnThreeHeader, footerColumnThreeContent), 7254 Design = new Design 7255 { 7256 Size = "auto", 7257 RenderType = RenderType.Column 7258 } 7259 }; 7260 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnThree); 7261 } 7262 7263 if (Model.Area.Item.GetItem("Layout").GetBoolean("FooterNewsletterSignUp")) 7264 { 7265 Block masterFooterNewsletterSignUp = new Block 7266 { 7267 Id = "MasterFooterNewsletterSignUp", 7268 SortId = 40, 7269 Template = RenderFooterNewsletterSignUp(), 7270 Design = new Design 7271 { 7272 Size = "auto", 7273 RenderType = RenderType.Column 7274 } 7275 }; 7276 footerBlocksPage.Add("MasterFooterContent", masterFooterNewsletterSignUp); 7277 } 7278 7279 if (Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks").Count > 0) 7280 { 7281 Block masterFooterSocialLinks = new Block 7282 { 7283 Id = "MasterFooterSocialLinks", 7284 SortId = 50, 7285 Template = RenderFooterSocialLinks(), 7286 Design = new Design 7287 { 7288 Size = "auto", 7289 RenderType = RenderType.Column 7290 } 7291 }; 7292 footerBlocksPage.Add("MasterFooterContent", masterFooterSocialLinks); 7293 } 7294 7295 if (Model.Area.Item.GetItem("Layout").GetItems("FooterPayments") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterPayments").Count > 0) 7296 { 7297 Block masterFooterPayments = new Block 7298 { 7299 Id = "MasterFooterPayments", 7300 SortId = 60, 7301 Template = RenderFooterPayments(), 7302 Design = new Design 7303 { 7304 Size = "12", 7305 RenderType = RenderType.Column 7306 } 7307 }; 7308 footerBlocksPage.Add("MasterFooterContent", masterFooterPayments); 7309 } 7310 7311 Block masterFooterCopyright = new Block 7312 { 7313 Id = "MasterFooterCopyright", 7314 SortId = 70, 7315 Template = RenderFooterCopyright(), 7316 Design = new Design 7317 { 7318 Size = "12", 7319 RenderType = RenderType.Column 7320 } 7321 }; 7322 footerBlocksPage.Add("MasterFooterContent", masterFooterCopyright); 7323 } 7324 7325 @helper RenderFooter() 7326 { 7327 List<Block> subBlocks = this.footerBlocksPage.GetBlockListById("MasterFooterContent").OrderBy(item => item.SortId).ToList(); 7328 7329 <footer class="footer no-print dw-mod"> 7330 <div class="center-container top-container__center-container dw-mod"> 7331 <div class="grid grid--external-bleed-x"> 7332 @RenderBlockList(subBlocks) 7333 </div> 7334 </div> 7335 </footer> 7336 } 7337 7338 @helper RenderFooterColumn(string header, string content) 7339 { 7340 <h3 class="footer__heading dw-mod">@header</h3> 7341 <div class="footer__content dw-mod"> 7342 @content 7343 </div> 7344 } 7345 7346 @helper RenderFooterNewsletterSignUp() 7347 { 7348 string newsletterSignUpPageId = GetPageIdByNavigationTag("NewsletterSignUp").ToString(); 7349 Form form = new Form { Action = "/Default.aspx", Method = FormMethod.Get, Enctype = FormEnctype.multipart }; 7350 7351 form.Add(new HiddenField { Name = "ID", Value = newsletterSignUpPageId }); 7352 form.Add(new Text { Content = "<p>" + Translate("Sign up if you would like to receive occasional treats from us") + "</p>" }); 7353 form.Add(new TextField { 7354 Id = "NewsletterEmail", Name = "NewsletterEmail", Placeholder = Translate("Your email address"), 7355 Type = TextFieldType.Email, 7356 ActionButton = new Button { 7357 ButtonType = ButtonType.Submit, Id="Submitter", Title = Translate("Go"), OnClick = "Buttons.LockButton(event)", CssClass = "btn--condensed" 7358 } 7359 }); 7360 7361 <h3 class="footer__heading dw-mod">@Translate("Mailing list")</h3> 7362 <div class="footer__content dw-mod"> 7363 @Render(form) 7364 </div> 7365 } 7366 7367 @helper RenderFooterSocialLinks() 7368 { 7369 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3> 7370 <div class="footer__content dw-mod"> 7371 <div class="collection dw-mod"> 7372 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks")) 7373 { 7374 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel; 7375 string socialIconClass = socialIcon.SelectedValue; 7376 string socialIconTitle = socialIcon.SelectedName; 7377 string socialLink = socialitem.GetString("Link"); 7378 7379 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a> 7380 } 7381 </div> 7382 </div> 7383 } 7384 7385 @helper RenderFooterPayments() 7386 { 7387 <div class="footer__content dw-mod"> 7388 <div class="collection dw-mod"> 7389 @foreach (var payment in Model.Area.Item.GetItem("Layout").GetItems("FooterPayments")) 7390 { 7391 var paymentItem = payment.GetValue("CardTypeOrVerifiedPayment") as Dynamicweb.Frontend.ListViewModel; 7392 string paymentImage = null; 7393 string paymentTitle = paymentItem.SelectedName; 7394 ListOptionViewModel selected = paymentItem.SelectedOptions.FirstOrDefault(); 7395 if (selected != null) 7396 { 7397 paymentImage = selected.Icon; 7398 } 7399 7400 <div class="footer__card-type"> 7401 <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" /> 7402 </div> 7403 } 7404 </div> 7405 </div> 7406 } 7407 7408 @helper RenderFooterCopyright() 7409 { 7410 <div class="grid__col-12 footer__copyright dw-mod"> 7411 <p>@Model.Area.Item.GetItem("Layout").GetString("FooterCopyrightText") - Laget av <a href="https://www.mennt.no" target="_blank">mennt.no</a></p> 7412 </div> 7413 } 7414 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 7415 7416 @using System 7417 @using System.Web 7418 @using System.Collections.Generic 7419 @using Dynamicweb.Rapido.Blocks.Extensibility 7420 @using Dynamicweb.Rapido.Blocks 7421 @using Dynamicweb.Ecommerce.Common 7422 7423 @{ 7424 BlocksPage referencesBlocksPage = BlocksPage.GetBlockPage("Master"); 7425 7426 Block masterScriptReferences = new Block() 7427 { 7428 Id = "MasterScriptReferences", 7429 SortId = 1, 7430 Template = RenderMasterScriptReferences() 7431 }; 7432 referencesBlocksPage.Add(MasterBlockId.MasterReferences, masterScriptReferences); 7433 } 7434 7435 @helper RenderMasterScriptReferences() { 7436 <script src="/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"></script> 7437 <script src="/Files/Templates/Designs/Rapido/js/master.min.js"></script> 7438 7439 if (Model.Area.Item.GetItem("Custom").GetBoolean("UseCustomJavascript")) 7440 { 7441 <script src="/Files/Templates/Designs/Rapido/js/custom.min.js"></script> 7442 PushPromise("/Files/Templates/Designs/Rapido/js/custom.min.js"); 7443 } 7444 7445 PushPromise("/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"); 7446 PushPromise("/Files/Templates/Designs/Rapido/js/master.min.js"); 7447 } 7448 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 7449 7450 @using System 7451 @using System.Web 7452 @using System.Collections.Generic 7453 @using Dynamicweb.Rapido.Blocks.Extensibility 7454 @using Dynamicweb.Rapido.Blocks 7455 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7456 @using Dynamicweb.Rapido.Services 7457 7458 @{ 7459 BlocksPage searchBlocksPage = BlocksPage.GetBlockPage("Master"); 7460 bool navigationItemsHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch"); 7461 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID")); 7462 7463 if (!navigationItemsHideSearch || isFavoriteList) 7464 { 7465 Block masterSearchScriptTemplates = new Block() 7466 { 7467 Id = "MasterSearchScriptTemplates", 7468 SortId = 1, 7469 Template = RenderSearchScriptTemplates() 7470 }; 7471 7472 searchBlocksPage.Add(MasterBlockId.MasterBottomSnippets, masterSearchScriptTemplates); 7473 } 7474 } 7475 7476 @helper RenderSearchScriptTemplates() 7477 { 7478 int productsPageId = GetPageIdByNavigationTag("ProductsPage"); 7479 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID; 7480 bool useFacebookPixel = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID")); 7481 bool useGoogleTagManager = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID")); 7482 bool showPrice = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HidePriceInSearchResults"); 7483 bool showAddToCartButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideAddToCartButton"); 7484 bool showViewButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideViewButton"); 7485 bool showAddToDownloadButton = Pageview.AreaSettings.GetItem("Layout").GetBoolean("ShowAddToDownloadButton"); 7486 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 7487 7488 <script id="SearchGroupsTemplate" type="text/x-template"> 7489 {{#.}} 7490 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li> 7491 {{/.}} 7492 </script> 7493 7494 <script id="SearchProductsTemplate" type="text/x-template"> 7495 {{#each .}} 7496 {{#Product}} 7497 {{#ifCond template "!==" "SearchMore"}} 7498 <li class="dropdown__item dropdown__item--seperator dw-mod"> 7499 @if (useFacebookPixel) 7500 { 7501 <text>{{{facebookPixelSearch name number priceDouble currency searchParameter}}}</text> 7502 } 7503 @if (useGoogleTagManager) 7504 { 7505 <text>{{{googleEnchantImpression googleImpression}}}</text> 7506 } 7507 <div> 7508 <a href="{{link}}" 7509 class="js-typeahead-link u-color-inherit u-pull--left" 7510 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" 7511 title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}"> 7512 <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> 7513 <div class="u-pull--left"> 7514 <div class="u-bold u-max-w220px u-truncate-text js-typeahead-name">{{name}}{{#if variantName}}, {{variantName}}{{/if}}</div> 7515 @if (showPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 7516 { 7517 if (pointShopOnly) 7518 { 7519 <text> 7520 {{#if havePointPrice}} 7521 <div> 7522 <span class="u-color--loyalty-points">{{points}}</span> @Translate("points") 7523 </div> 7524 {{else}} 7525 <small class="help-text u-no-margin">@Translate("Not available")</small> 7526 {{/if}} 7527 {{#unless canBePurchasedWithPoints}} 7528 {{#if havePointPrice}} 7529 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 7530 {{/if}} 7531 {{/unless}} 7532 </text> 7533 } 7534 else 7535 { 7536 <div>{{price}}</div> 7537 } 7538 } 7539 </div> 7540 </a> 7541 <div class="u-margin-left u-pull--right"> 7542 @{ 7543 var viewBtn = new Link 7544 { 7545 Href = "{{link}}", 7546 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 7547 ButtonLayout = ButtonLayout.Secondary, 7548 CssClass = "btn--condensed u-no-margin u-w80px js-ignore-click-outside", 7549 Title = Translate("View") 7550 }; 7551 } 7552 @if (showAddToCartButton && Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 7553 { 7554 <text>{{#ifCond hideBuyButton '==' 'False'}}</text> 7555 @Render(new AddToCartButton 7556 { 7557 HideTitle = true, 7558 ProductId = "{{productId}}", 7559 ProductInfo = "{{productInfo}}", 7560 BuyForPoints = pointShopOnly, 7561 OnClick = "{{facebookPixelAction}}", 7562 CssClass = "u-w80px u-no-margin js-ignore-click-outside", 7563 Icon = new Icon { 7564 CssClass = "js-ignore-click-outside" 7565 }, 7566 ExtraAttributes = new Dictionary<string, string> 7567 { 7568 { "{{disabledBuyButton}}", "" } 7569 } 7570 }) 7571 <text>{{else}}</text> 7572 @Render(viewBtn) 7573 <text>{{/ifCond}}</text> 7574 } 7575 else if (showViewButton) 7576 { 7577 @Render(viewBtn) 7578 } 7579 @if (showAddToDownloadButton) 7580 { 7581 <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}}"> 7582 <i class="fas fa-plus js-button-icon"></i> 7583 </button> 7584 } 7585 </div> 7586 </div> 7587 </li> 7588 {{/ifCond}} 7589 {{#ifCond template "===" "SearchMore"}} 7590 {{>SearchMoreProducts}} 7591 {{/ifCond}} 7592 {{/Product}} 7593 {{else}} 7594 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod"> 7595 @Translate("Your search gave 0 results") 7596 </li> 7597 {{/each}} 7598 </script> 7599 7600 <script id="SearchMoreProducts" type="text/x-template"> 7601 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod"> 7602 <a href="/Default.aspx?ID=@productsPageId&Search={{searchParameter}}&GroupID={{groupId}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> 7603 @Translate("View all") 7604 </a> 7605 </li> 7606 </script> 7607 7608 <script id="SearchMorePages" type="text/x-template"> 7609 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod"> 7610 <a href="/Default.aspx?ID=@contentSearchPageLink&Search={{searchParameter}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> 7611 @Translate("View all") 7612 </a> 7613 </li> 7614 </script> 7615 7616 <script id="SearchPagesTemplate" type="text/x-template"> 7617 {{#each .}} 7618 {{#ifCond template "!==" "SearchMore"}} 7619 <li class="dropdown__item dropdown__item--seperator dropdown__item--no-padding dw-mod"> 7620 <a href="/Default.aspx?ID={{id}}" class="js-typeahead-link dropdown__link u-color-inherit"> 7621 <div class="u-margin-right u-inline"><i class="fa {{icon}} u-w20px u-ta-center"></i></div> 7622 <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> 7623 </a> 7624 </li> 7625 {{/ifCond}} 7626 {{#ifCond template "===" "SearchMore"}} 7627 {{>SearchMorePages}} 7628 {{/ifCond}} 7629 {{else}} 7630 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod"> 7631 @Translate("Your search gave 0 results") 7632 </li> 7633 {{/each}} 7634 </script> 7635 7636 <script id="SearchPagesTemplateWrap" type="text/x-template"> 7637 <div class="dropdown__column-header">@Translate("Pages")</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 {{>SearchPagesTemplate}} 7640 </ul> 7641 </script> 7642 7643 <script id="SearchProductsTemplateWrap" type="text/x-template"> 7644 <div class="dropdown__column-header">@Translate("Products")</div> 7645 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod"> 7646 {{>SearchProductsTemplate}} 7647 </ul> 7648 </script> 7649 } 7650 7651 @using Dynamicweb.Rapido.Blocks.Components 7652 @using Dynamicweb.Rapido.Blocks.Components.General 7653 @using Dynamicweb.Rapido.Blocks 7654 @using System.IO 7655 7656 7657 @using Dynamicweb.Rapido.Blocks.Components.General 7658 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7659 7660 7661 @* Component *@ 7662 7663 @helper RenderVariantMatrix(VariantMatrix settings) { 7664 if (settings != null) 7665 { 7666 int productLoopCounter = 0; 7667 int groupCount = 0; 7668 List<VariantOption> firstDimension = new List<VariantOption>(); 7669 List<VariantOption> secondDimension = new List<VariantOption>(); 7670 List<VariantOption> thirdDimension = new List<VariantOption>(); 7671 7672 foreach (VariantGroup variantGroup in settings.GetVariantGroups()) 7673 { 7674 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions()) 7675 { 7676 if (groupCount == 0) { 7677 firstDimension.Add(variantOptions); 7678 } 7679 if (groupCount == 1) 7680 { 7681 secondDimension.Add(variantOptions); 7682 } 7683 if (groupCount == 2) 7684 { 7685 thirdDimension.Add(variantOptions); 7686 } 7687 } 7688 groupCount++; 7689 } 7690 7691 int rowCount = 0; 7692 int columnCount = 0; 7693 7694 <script> 7695 var variantsCollection = []; 7696 </script> 7697 7698 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId"> 7699 @if (groupCount == 1) 7700 { 7701 <tbody> 7702 @foreach (VariantOption firstVariantOption in firstDimension) 7703 { 7704 var variantId = firstVariantOption.Id; 7705 <tr> 7706 <td class="u-bold"> 7707 @firstVariantOption.Name 7708 </td> 7709 <td> 7710 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7711 </td> 7712 </tr> 7713 productLoopCounter++; 7714 } 7715 7716 <tr> 7717 <td>&nbsp;</td> 7718 <td> 7719 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7720 </td> 7721 </tr> 7722 </tbody> 7723 } 7724 @if (groupCount == 2) 7725 { 7726 <thead> 7727 <tr> 7728 <td>&nbsp;</td> 7729 @foreach (VariantOption variant in secondDimension) 7730 { 7731 <td>@variant.Name</td> 7732 } 7733 </tr> 7734 </thead> 7735 <tbody> 7736 @foreach (VariantOption firstVariantOption in firstDimension) 7737 { 7738 string variantId = ""; 7739 columnCount = 0; 7740 7741 <tr> 7742 <td class="u-min-w120px">@firstVariantOption.Name</td> 7743 7744 @foreach (VariantOption secondVariantOption in secondDimension) 7745 { 7746 variantId = firstVariantOption.Id + "." + secondVariantOption.Id; 7747 <td> 7748 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7749 </td> 7750 7751 columnCount++; 7752 7753 productLoopCounter++; 7754 } 7755 7756 <td> 7757 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 7758 </td> 7759 </tr> 7760 7761 rowCount++; 7762 } 7763 7764 @{ 7765 columnCount = 0; 7766 } 7767 7768 <tr> 7769 <td>&nbsp;</td> 7770 @foreach (VariantOption secondVariantOption in secondDimension) 7771 { 7772 <td> 7773 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7774 </td> 7775 7776 columnCount++; 7777 } 7778 <td>&nbsp;</td> 7779 </tr> 7780 </tbody> 7781 } 7782 @if (groupCount == 3) 7783 { 7784 <thead> 7785 <tr> 7786 <td>&nbsp;</td> 7787 @foreach (VariantOption thirdVariantOption in thirdDimension) 7788 { 7789 <td>@thirdVariantOption.Name</td> 7790 } 7791 </tr> 7792 </thead> 7793 <tbody> 7794 @foreach (VariantOption firstVariantOption in firstDimension) 7795 { 7796 int colspan = (thirdDimension.Count + 1); 7797 7798 <tr> 7799 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td> 7800 </tr> 7801 7802 foreach (VariantOption secondVariantOption in secondDimension) 7803 { 7804 string variantId = ""; 7805 columnCount = 0; 7806 7807 <tr> 7808 <td class="u-min-w120px">@secondVariantOption.Name</td> 7809 7810 @foreach (VariantOption thirdVariantOption in thirdDimension) 7811 { 7812 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id; 7813 7814 <td> 7815 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 7816 </td> 7817 7818 columnCount++; 7819 productLoopCounter++; 7820 } 7821 7822 <td> 7823 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 7824 </td> 7825 </tr> 7826 rowCount++; 7827 } 7828 } 7829 7830 @{ 7831 columnCount = 0; 7832 } 7833 7834 <tr> 7835 <td>&nbsp;</td> 7836 @foreach (VariantOption thirdVariantOption in thirdDimension) 7837 { 7838 <td> 7839 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 7840 </td> 7841 7842 columnCount++; 7843 } 7844 <td>&nbsp;</td> 7845 </tr> 7846 </tbody> 7847 } 7848 </table> 7849 7850 <script> 7851 document.addEventListener("DOMContentLoaded", function (event) { 7852 MatrixUpdateQuantity("@settings.ProductId"); 7853 }); 7854 7855 MatrixUpdateQuantity = function (productId) { 7856 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId); 7857 var allQtyFields = currentMatrix.getElementsByClassName("js-qty"); 7858 7859 var qtyRowArr = []; 7860 var qtyColumnArr = []; 7861 7862 var totalQty = 0; 7863 7864 for (var i = 0; i < allQtyFields.length; i++) { 7865 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0; 7866 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0; 7867 } 7868 7869 for (var i = 0; i < allQtyFields.length; i++) { 7870 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value); 7871 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value); 7872 totalQty += parseFloat(allQtyFields[i].value); 7873 } 7874 7875 //Update row counters 7876 for (var i = 0; i < qtyRowArr.length; i++) { 7877 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 7878 7879 if (qtyRowArr[i] != undefined && qtyCounter != null) { 7880 var currentCount = qtyCounter.innerHTML; 7881 qtyCounter.innerHTML = qtyRowArr[i]; 7882 7883 if (currentCount != qtyCounter.innerHTML) { 7884 qtyCounter.classList.add("qty-field--active"); 7885 } 7886 } 7887 7888 } 7889 7890 //Update column counters 7891 for (var i = 0; i < qtyColumnArr.length; i++) { 7892 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 7893 7894 if (qtyColumnArr[i] != undefined && qtyCounter != null) { 7895 var currentCount = qtyCounter.innerHTML; 7896 qtyCounter.innerHTML = qtyColumnArr[i]; 7897 7898 if (currentCount != qtyCounter.innerHTML) { 7899 qtyCounter.classList.add("qty-field--active"); 7900 } 7901 } 7902 } 7903 7904 if (document.getElementById("TotalQtyCount_" + productId)) { 7905 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty; 7906 } 7907 7908 //Clean up animations 7909 setTimeout(function () { 7910 for (var i = 0; i < qtyRowArr.length; i++) { 7911 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 7912 if (qtyCounter != null) { 7913 qtyCounter.classList.remove("qty-field--active"); 7914 } 7915 } 7916 for (var i = 0; i < qtyColumnArr.length; i++) { 7917 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 7918 if (qtyCounter != null) { 7919 qtyCounter.classList.remove("qty-field--active"); 7920 } 7921 } 7922 }, 1000); 7923 } 7924 </script> 7925 } 7926 } 7927 7928 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount) 7929 { 7930 string loopCount = productLoopCounter.ToString(); 7931 7932 bool combinationFound = false; 7933 double stock = 0; 7934 double quantityValue = 0; 7935 string note = ""; 7936 7937 VariantProduct variantProduct = null; 7938 7939 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct)) 7940 { 7941 stock = variantProduct.Stock; 7942 quantityValue = variantProduct.Quantity; 7943 combinationFound = true; 7944 } 7945 7946 if (combinationFound) 7947 { 7948 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" /> 7949 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" /> 7950 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" /> 7951 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" /> 7952 <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"> 7953 7954 if (stock != 0) 7955 { 7956 <small>@Translate("Stock") @stock</small> 7957 } 7958 7959 <script> 7960 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}'; 7961 variantsCollection.push(variants); 7962 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" ); 7963 </script> 7964 } 7965 else 7966 { 7967 <div class="use-btn-height" style="background-color: #a8a8a8"></div> 7968 } 7969 } 7970 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 7971 7972 @* Component *@ 7973 7974 @helper RenderAddToCart(AddToCart settings) 7975 { 7976 //set Id for quantity selector to get it's value from button 7977 if (settings.QuantitySelector != null) 7978 { 7979 if (string.IsNullOrEmpty(settings.QuantitySelector.Id)) 7980 { 7981 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N"); 7982 } 7983 7984 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id; 7985 7986 if (settings.Disabled) 7987 { 7988 settings.QuantitySelector.Disabled = true; 7989 } 7990 7991 if (string.IsNullOrEmpty(settings.QuantitySelector.Name)) 7992 { 7993 settings.QuantitySelector.Name = settings.QuantitySelector.Id; 7994 } 7995 } 7996 7997 if (settings.Disabled) 7998 { 7999 settings.AddButton.Disabled = true; 8000 } 8001 8002 settings.AddButton.CssClass += " btn--condensed"; 8003 8004 //unitsSelector 8005 if (settings.UnitSelector != null) 8006 { 8007 if (settings.Disabled) 8008 { 8009 settings.QuantitySelector.Disabled = true; 8010 } 8011 } 8012 8013 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 8014 @if (settings.UnitSelector != null) 8015 { 8016 @Render(settings.UnitSelector) 8017 } 8018 @if (settings.QuantitySelector != null) 8019 { 8020 @Render(settings.QuantitySelector) 8021 } 8022 @Render(settings.AddButton) 8023 </div> 8024 } 8025 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 8026 8027 @* Component *@ 8028 8029 @helper RenderAddToCartButton(AddToCartButton settings) 8030 { 8031 if (!settings.HideTitle) 8032 { 8033 if (string.IsNullOrEmpty(settings.Title)) 8034 { 8035 if (settings.BuyForPoints) 8036 { 8037 settings.Title = Translate("Buy with points"); 8038 } 8039 else 8040 { 8041 settings.Title = Translate("Add to cart"); 8042 } 8043 } 8044 } 8045 else 8046 { 8047 settings.Title = ""; 8048 } 8049 8050 if (settings.Icon == null) 8051 { 8052 settings.Icon = new Icon(); 8053 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After; 8054 } 8055 8056 if (string.IsNullOrEmpty(settings.Icon.Name)) 8057 { 8058 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue; 8059 } 8060 8061 settings.OnClick = "Cart.AddToCart(event, { " + 8062 "id: '" + settings.ProductId + "'," + 8063 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") + 8064 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") + 8065 (settings.BuyForPoints ? "buyForPoints: true," : "") + 8066 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") + 8067 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") + 8068 "});" + settings.OnClick; 8069 8070 @RenderButton(settings) 8071 } 8072 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 8073 8074 @* Component *@ 8075 8076 @helper RenderUnitSelector(UnitSelector settings) 8077 { 8078 if (string.IsNullOrEmpty(settings.Id)) 8079 { 8080 settings.Id = Guid.NewGuid().ToString("N"); 8081 } 8082 var disabledClass = settings.Disabled ? "disabled" : ""; 8083 8084 <input type="checkbox" id="@settings.Id" class="dropdown-trigger" /> 8085 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 8086 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@settings.Id">@settings.SelectedOption</label> 8087 <div class="dropdown__content dw-mod"> 8088 @settings.OptionsContent 8089 </div> 8090 <label class="dropdown-trigger-off" for="@settings.Id"></label> 8091 </div> 8092 } 8093 @using System.Reflection 8094 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 8095 8096 @* Component *@ 8097 8098 @helper RenderQuantitySelector(QuantitySelector settings) 8099 { 8100 var attributes = new Dictionary<string, string>(); 8101 8102 /*base settings*/ 8103 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 8104 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 8105 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 8106 if (settings.Disabled) { attributes.Add("disabled", "true"); } 8107 if (settings.Required) { attributes.Add("required", "true"); } 8108 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 8109 /*end*/ 8110 8111 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 8112 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 8113 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 8114 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 8115 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 8116 if (settings.Min == null) { settings.Min = 1; } 8117 attributes.Add("min", settings.Min.ToString()); 8118 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); } 8119 if (settings.Value == null) { settings.Value = 1; } 8120 attributes.Add("value", settings.Value.ToString()); 8121 attributes.Add("type", "number"); 8122 8123 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 8124 8125 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 8126 } 8127 @using Dynamicweb.Rapido.Blocks.Components 8128 8129 @using Dynamicweb.Frontend 8130 @using Dynamicweb.Frontend.Devices 8131 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 8132 @using Dynamicweb.Rapido.Blocks.Components.General 8133 @using System.Collections.Generic; 8134 8135 @* Component *@ 8136 8137 @helper RenderCustomerCenterList(CustomerCenterList settings) 8138 { 8139 bool isTouchDevice = Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet" ? true : false; 8140 string hideActions = isTouchDevice ? "u-block" : ""; 8141 8142 <table class="table data-list dw-mod"> 8143 @if (settings.GetHeaders().Length > 0) { 8144 <thead> 8145 <tr class="u-bold"> 8146 @foreach (CustomerCenterListHeaderItem header in settings.GetHeaders()) 8147 { 8148 var attributes = new Dictionary<string, string>(); 8149 if (!string.IsNullOrEmpty(header.Id)) { attributes.Add("id", header.Id); } 8150 if (!string.IsNullOrEmpty(header.CssClass)) { attributes.Add("class", header.CssClass); } 8151 attributes.Add("align", header.Align.ToString()); 8152 attributes = attributes.Concat(header.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 8153 8154 <td @ComponentMethods.AddAttributes(attributes)>@header.Title</td> 8155 } 8156 </tr> 8157 </thead> 8158 } 8159 @foreach (CustomerCenterListItem listItem in settings.GetItems()) 8160 { 8161 int columnCount = 0; 8162 int totalColumns = listItem.GetInfoItems().Length; 8163 string rowHasActions = listItem.GetActions().Length > 0 ? "data-list__item--has-actions" : ""; 8164 listItem.Id = !string.IsNullOrEmpty(listItem.Id) ? listItem.Id : Guid.NewGuid().ToString("N"); 8165 8166 var attributes = new Dictionary<string, string>(); 8167 if (!string.IsNullOrEmpty(listItem.Title)) { attributes.Add("title", listItem.Title); }; 8168 8169 attributes = attributes.Concat(listItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 8170 <tbody class="data-list__item @rowHasActions @listItem.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes)> 8171 <tr> 8172 @if (!string.IsNullOrEmpty(listItem.Title) || !string.IsNullOrEmpty(listItem.Description)) { 8173 string onClick = !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 8174 8175 <td rowspan="2" @onClick class="data-list__main-item dw-mod"> 8176 @if (!string.IsNullOrEmpty(listItem.Title)) { 8177 <div class="u-bold">@listItem.Title</div> 8178 } 8179 @if (!string.IsNullOrEmpty(listItem.Description)) { 8180 <div>@listItem.Description</div> 8181 } 8182 </td> 8183 } 8184 8185 @foreach (CustomerCenterListInfoItem infoItem in listItem.GetInfoItems()) 8186 { 8187 var infoAttributes = new Dictionary<string, string>(); 8188 if (!string.IsNullOrEmpty(infoItem.Id)) { infoAttributes.Add("id", infoItem.Id); }; 8189 if (!string.IsNullOrEmpty(infoItem.OnClick)) { infoAttributes.Add("onclick", infoItem.OnClick); }; 8190 infoAttributes.Add("align", infoItem.Align.ToString()); 8191 8192 infoAttributes = infoAttributes.Concat(infoItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 8193 string columnClick = columnCount < (totalColumns-1) && !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 8194 8195 <td @ComponentMethods.AddAttributes(infoAttributes) @columnClick class="data-list__info-item dw-mod"> 8196 @if (!string.IsNullOrEmpty(infoItem.Title)) { 8197 <div>@infoItem.Title</div> 8198 } 8199 @if (!string.IsNullOrEmpty(infoItem.Subtitle)) { 8200 <div><small>@infoItem.Subtitle</small></div> 8201 } 8202 </td> 8203 8204 columnCount++; 8205 } 8206 </tr> 8207 <tr> 8208 <td colspan="7" align="right" class="u-va-bottom u-no-border"> 8209 <div class="data-list__actions @hideActions dw-mod" id="ActionsMenu_@listItem.Id"> 8210 @foreach (ButtonBase action in listItem.GetActions()) 8211 { 8212 action.ButtonLayout = ButtonLayout.LinkClean; 8213 action.Icon.CssClass += " u-full-height"; 8214 action.CssClass += " data-list__action-button link"; 8215 8216 @Render(action) 8217 } 8218 </div> 8219 </td> 8220 </tr> 8221 </tbody> 8222 } 8223 </table> 8224 } 8225 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 8226 8227 @using System 8228 @using System.Web 8229 @using System.Collections.Generic 8230 @using Dynamicweb.Rapido.Blocks.Extensibility 8231 @using Dynamicweb.Rapido.Blocks 8232 8233 @{ 8234 BlocksPage bottomSnippetsBlocksPage = BlocksPage.GetBlockPage("Master"); 8235 8236 Block primaryBottomSnippets = new Block() 8237 { 8238 Id = "MasterJavascriptInitializers", 8239 SortId = 100, 8240 Template = RenderPrimaryBottomSnippets() 8241 }; 8242 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, primaryBottomSnippets); 8243 8244 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 8245 { 8246 Block miniCartPageId = new Block 8247 { 8248 Id = "MiniCartPageId", 8249 Template = RenderMiniCartPageId() 8250 }; 8251 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, miniCartPageId); 8252 } 8253 } 8254 8255 @helper RenderPrimaryBottomSnippets() 8256 { 8257 bool isWireframeMode = Model.Area.Item.GetItem("Settings").GetBoolean("WireframeMode"); 8258 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 8259 8260 if (isWireframeMode) 8261 { 8262 <script> 8263 Wireframe.Init(true); 8264 </script> 8265 } 8266 8267 8268 if (useGoogleTagManager) 8269 { 8270 @*<script> 8271 document.addEventListener('addToCart', function(event) { 8272 var googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 8273 if (typeof googleImpression == "string") { 8274 googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 8275 } 8276 dataLayer.push({ 8277 'event': 'addToCart', 8278 'ecommerce': { 8279 'currencyCode': googleImpression.currency, 8280 'add': { 8281 'products': [{ 8282 'name': googleImpression.name, 8283 'id': googleImpression.id, 8284 'price': googleImpression.price, 8285 'brand': googleImpression.brand, 8286 'category': googleImpression.category, 8287 'variant': googleImpression.variant, 8288 'quantity': event.detail.quantity 8289 }] 8290 } 8291 } 8292 }); 8293 }); 8294 </script>*@ 8295 8296 <script> 8297 document.addEventListener('addToCart', function(event) { 8298 var googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 8299 if (typeof googleImpression == "string") { 8300 googleImpression = JSON.parse(event.detail.productInfo.googleImpression); 8301 } 8302 8303 gtag("event", "add_to_cart", { 8304 currency: googleImpression.currency, 8305 value: googleImpression.price, 8306 items: [ 8307 { 8308 item_id: googleImpression.id, 8309 item_name: googleImpression.name, 8310 item_variant: googleImpression.variant, 8311 currency: googleImpression.currency, 8312 item_list_id: "", 8313 price: googleImpression.price, 8314 quantity: event.detail.quantity 8315 } 8316 ] 8317 }); 8318 }); 8319 </script> 8320 } 8321 8322 //if digitalwarehouse 8323 if (Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart")) 8324 { 8325 string cartContextId = Converter.ToString(HttpContext.Current.Application["DownloadCartContext"]); 8326 8327 if (string.IsNullOrEmpty(cartContextId)) 8328 { 8329 var moduleProps = Dynamicweb.Modules.Properties.GetParagraphModuleSettings(GetPageIdByNavigationTag("DownloadCart"), "eCom_CartV2"); 8330 var cartSettings = new Dynamicweb.Ecommerce.Cart.ModuleSettings(moduleProps); 8331 cartContextId = cartSettings.OrderContextID; 8332 HttpContext.Current.Application["DownloadCartContext"] = cartContextId; 8333 } 8334 8335 <script> 8336 let downloadCart = new DownloadCart({ 8337 cartPageId: @GetPageIdByNavigationTag("MiniCartFeed"), 8338 contextId: "@cartContextId", 8339 addButtonText: "@Translate("Add")", 8340 removeButtonText: "@Translate("Remove")" 8341 }); 8342 </script> 8343 } 8344 8345 <!--$$Javascripts--> 8346 } 8347 8348 @helper RenderMiniCartPageId() 8349 { 8350 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed"); 8351 <script> 8352 window.cartId = "@miniCartFeedPageId"; 8353 </script> 8354 } 8355 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 8356 8357 @using System 8358 @using System.Web 8359 @using System.Collections.Generic 8360 @using Dynamicweb.Rapido.Blocks 8361 8362 @{ 8363 BlocksPage masterCustomBlocksPage = BlocksPage.GetBlockPage("Master"); 8364 8365 Block masterFooterSocialLinksCustom = new Block 8366 { 8367 Id = "MasterFooterSocialLinks", 8368 SortId = 50, 8369 Template = RenderFooterSocialLinksCustom(), 8370 Design = new Design 8371 { 8372 Size = "auto", 8373 RenderType = RenderType.Column 8374 } 8375 }; 8376 masterCustomBlocksPage.ReplaceBlock(masterFooterSocialLinksCustom); 8377 8378 masterCustomBlocksPage.RemoveBlockById("MasterDesktopToolsText"); 8379 8380 if (Pageview.AreaID != 25) 8381 { 8382 Block facebookChat = new Block 8383 { 8384 Id = "FacebookChat", 8385 SortId = 1, 8386 Template = RenderFacebookChat() 8387 }; 8388 masterCustomBlocksPage.Add("Body", facebookChat); 8389 } 8390 8391 Block googleAdsSiteTag = new Block() 8392 { 8393 Id = "GoogleAdsSiteTag", 8394 SortId = 3, 8395 Template = RenderGoogleAdsSiteTag() 8396 }; 8397 8398 masterCustomBlocksPage.Add("Head", googleAdsSiteTag); 8399 8400 Block facebookPixelCustom = new Block() 8401 { 8402 Id = "FacebookPixel", 8403 SortId = 2, 8404 Template = RenderFacebookPixelCustom() 8405 }; 8406 masterCustomBlocksPage.ReplaceBlock(facebookPixelCustom); 8407 } 8408 8409 @helper RenderFacebookPixelCustom() 8410 { 8411 string FacebookPixelID = Model.Area.Item.GetItem("Settings").GetString("FacebookPixelID"); 8412 string productId = System.Web.HttpContext.Current.Request.QueryString.Get("ProductID") != null ? System.Web.HttpContext.Current.Request.QueryString.Get("ProductID") : "0"; 8413 8414 if (!string.IsNullOrWhiteSpace(FacebookPixelID)) 8415 { 8416 <!-- Facebook Pixel Code --> 8417 <script> 8418 !function(f,b,e,v,n,t,s) 8419 {if(f.fbq)return;n=f.fbq=function(){n.callMethod? 8420 n.callMethod.apply(n,arguments):n.queue.push(arguments)}; 8421 if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; 8422 n.queue=[];t=b.createElement(e);t.async=!0; 8423 t.src=v;s=b.getElementsByTagName(e)[0]; 8424 s.parentNode.insertBefore(t,s)}(window, document,'script', 8425 'https://connect.facebook.net/en_US/fbevents.js'); 8426 fbq('init', '@FacebookPixelID'); 8427 fbq('track', 'PageView'); 8428 fbq('track', 'ViewContent', { 8429 content_ids: @productId, 8430 content_type: "product", 8431 8432 }); 8433 </script> 8434 <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=@FacebookPixelID&ev=PageView&noscript=1" alt="" /></noscript> 8435 } 8436 } 8437 8438 @helper RenderFooterSocialLinksCustom() 8439 { 8440 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3> 8441 <div class="footer__content dw-mod"> 8442 <div class="collection dw-mod"> 8443 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks")) 8444 { 8445 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel; 8446 string socialIconClass = socialIcon.SelectedValue; 8447 string socialIconTitle = socialIcon.SelectedName; 8448 string socialLink = socialitem.GetString("Link"); 8449 8450 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a> 8451 } 8452 </div> 8453 </div> 8454 8455 <div> 8456 <script src="//www.tryggehandel.no/?cid=1353&logo=1" alt="Trygg handel"></script> 8457 </div> 8458 8459 <div style="margin-top: 3rem; display: flex; flex-direction: column; align-items: flex-start;"> 8460 <img height="50" width="100" src="https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg" alt="Klarna" /> 8461 <img height="50" width="100" src="/Files/Images/Payment/vipps-rgb-orange-pos.svg" alt="Vipps" /> 8462 </div> 8463 } 8464 8465 @helper RenderFacebookChat() 8466 { 8467 <div></div> 8468 } 8469 8470 @helper RenderFacebookChatOld() 8471 { 8472 <!-- Messenger Chattillegg Code --> 8473 <div id="fb-root"></div> 8474 8475 <!-- Your Chattillegg code --> 8476 <div id="fb-customer-chat" 8477 class="fb-customerchat" 8478 logged_in_greeting='@Translate("fb_logged_in_greeting")' 8479 logged_out_greeting='@Translate("fb_logged_out_greeting")' 8480 theme_color="#364a55" 8481 greeting_dialog_display="hide"> 8482 8483 </div> 8484 8485 <script> 8486 var chatbox = document.getElementById('fb-customer-chat'); 8487 chatbox.setAttribute("page_id", "223600817672082"); 8488 chatbox.setAttribute("attribution", "biz_inbox"); 8489 </script> 8490 8491 <!-- Your SDK code --> 8492 <script> 8493 window.fbAsyncInit = function() { 8494 FB.init({ 8495 xfbml : true, 8496 version : 'v12.0' 8497 }); 8498 }; 8499 8500 (function(d, s, id) { 8501 var js, fjs = d.getElementsByTagName(s)[0]; 8502 if (d.getElementById(id)) return; 8503 js = d.createElement(s); js.id = id; 8504 js.src = 'https://connect.facebook.net/nb_NO/sdk/xfbml.customerchat.js'; 8505 fjs.parentNode.insertBefore(js, fjs); 8506 }(document, 'script', 'facebook-jssdk')); 8507 </script> 8508 } 8509 8510 @helper RenderGoogleAdsSiteTag() 8511 { 8512 <!-- Global site tag (gtag.js) - Google Ads: 1000865186 --> 8513 <script async src="https://www.googletagmanager.com/gtag/js?id=AW-1000865186"></script> 8514 <script> 8515 window.dataLayer = window.dataLayer || []; 8516 function gtag(){dataLayer.push(arguments);} 8517 gtag('js', new Date()); 8518 8519 gtag('config', 'AW-1000865186'); 8520 </script> 8521 } 8522 8523 8524 @functions { 8525 public class ManifestIcon 8526 { 8527 public string src { get; set; } 8528 public string type { get; set; } 8529 public string sizes { get; set; } 8530 } 8531 8532 public class Manifest 8533 { 8534 public string name { get; set; } 8535 public string short_name { get; set; } 8536 public string start_url { get; set; } 8537 public string display { get; set; } 8538 public string background_color { get; set; } 8539 public string theme_color { get; set; } 8540 public List<ManifestIcon> icons { get; set; } 8541 } 8542 } 8543 8544 <!DOCTYPE html> 8545 8546 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName"> 8547 8548 8549 8550 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 8551 @RenderBlockList(masterPage.BlocksRoot.BlocksList) 8552 8553 8554 8555 @helper RenderMasterHead() { 8556 List<Block> subBlocks = this.masterPage.GetBlockListById("Head").OrderBy(item => item.SortId).ToList(); 8557 8558 <head> 8559 <!-- Rapido version 3.4.2 --> 8560 8561 @RenderBlockList(subBlocks) 8562 </head> 8563 } 8564 8565 @helper RenderMasterMetadata() { 8566 var swatches = new Dynamicweb.Content.Items.ColorSwatchService(); 8567 var brandColors = swatches.GetColorSwatch(1); 8568 string brandColorOne = brandColors.Palette["BrandColor1"]; 8569 8570 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")) && Model.Area.Item.GetItem("Settings").GetFile("AppIcon") != null) { 8571 Manifest manifest = new Manifest 8572 { 8573 name = Model.Area.Item.GetItem("Settings").GetString("AppName"), 8574 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"), 8575 start_url = "/", 8576 display = "standalone", 8577 background_color = Model.Area.Item.GetItem("Settings").GetString("AppBackgroundColor"), 8578 theme_color = Model.Area.Item.GetItem("Settings").GetString("AppThemeColor") 8579 }; 8580 8581 manifest.icons = new List<ManifestIcon> { 8582 new ManifestIcon { 8583 src = "/Admin/Public/GetImage.ashx?width=192&height=192&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 8584 sizes = "192x192", 8585 type = "image/png" 8586 }, 8587 new ManifestIcon { 8588 src = "/Admin/Public/GetImage.ashx?width=512&height=512&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 8589 sizes = "512x512", 8590 type = "image/png" 8591 }, 8592 new ManifestIcon { 8593 src = "/Admin/Public/GetImage.ashx?width=1024&height=1024&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded, 8594 sizes = "1024x1024", 8595 type = "image/png" 8596 } 8597 }; 8598 8599 string manifestFilePath = HttpContext.Current.Request.MapPath("/Files/Templates/Designs/Rapido/manifest.json"); 8600 string manifestJSON = Newtonsoft.Json.JsonConvert.SerializeObject(manifest); 8601 string currentManifest = File.ReadAllText(manifestFilePath); 8602 8603 if (manifestJSON != currentManifest) 8604 { 8605 File.WriteAllText(manifestFilePath, manifestJSON); 8606 } 8607 } 8608 8609 <meta charset="utf-8" /> 8610 <title>@Model.Title</title> 8611 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 8612 <meta name="robots" content="index, follow"> 8613 <meta name="theme-color" content="@brandColorOne" /> 8614 8615 if (!Model.MetaTags.Contains("og:image")) { 8616 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"))); 8617 } 8618 8619 if (!Model.MetaTags.Contains("og:description")) { 8620 Pageview.Meta.AddTag("og:description", Model.Description); 8621 } 8622 8623 8624 Pageview.Meta.AddTag("og:title", Model.Title); 8625 Pageview.Meta.AddTag("og:site_name", Model.Name); 8626 Pageview.Meta.AddTag("og:url", string.Format("{0}{1}", "https://skadedyrbutikken.no", HttpContext.Current.Request.RawUrl.ToString())); 8627 Pageview.Meta.AddTag("og:type", "Website"); 8628 8629 if (!string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("FacebookAppID"))) { 8630 Pageview.Meta.AddTag("fb:app_id", Model.Area.Item.GetItem("Settings").GetString("FacebookAppID")); 8631 } 8632 8633 @Model.MetaTags 8634 } 8635 8636 @helper RenderMasterCss() { 8637 var fonts = new string[] { 8638 getFontFamily("Layout", "HeaderFont"), 8639 getFontFamily("Layout", "SubheaderFont"), 8640 getFontFamily("Layout", "TertiaryHeaderFont"), 8641 getFontFamily("Layout", "BodyText"), 8642 getFontFamily("Layout", "Header", "ToolsFont"), 8643 getFontFamily("Layout", "Header", "NavigationFont"), 8644 getFontFamily("Layout", "MobileNavigation", "Font"), 8645 getFontFamily("ProductList", "Facets", "HeaderFont"), 8646 getFontFamily("ProductPage", "PriceFontDesign"), 8647 getFontFamily("Ecommerce", "SaleSticker", "Font"), 8648 getFontFamily("Ecommerce", "NewSticker", "Font"), 8649 getFontFamily("Ecommerce", "CustomSticker", "Font") 8650 }; 8651 8652 string autoCssLink = "/Files/Templates/Designs/Rapido/css/rapido/rapido_" + Model.Area.ID.ToString() + ".min.css?ticks=" + Model.Area.UpdatedDate.Ticks; 8653 string test = "/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css" + "?ticks=" + Model.Area.UpdatedDate.Ticks; 8654 string favicon = Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon").Path : "/Files/Images/favicon.png"; 8655 bool useFontAwesomePro = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetBoolean("UseFontAwesomePro"); 8656 string fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomeFree/css/fontawesome-all.min.css"; 8657 if (useFontAwesomePro) 8658 { 8659 fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomePro/css/fontawesome-all.min.css"; 8660 } 8661 8662 //Favicon 8663 <link href="@favicon" rel="icon" type="image/png"> 8664 8665 //Base (Default, wireframe) styles 8666 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/base/base.min.css" type="text/css"> 8667 8668 //Rapido Css from Website Settings 8669 <link rel="stylesheet" id="rapidoCss" href="@autoCssLink" type="text/css"> 8670 8671 //Ignite Css (Custom site specific styles) 8672 <link rel="stylesheet" id="igniteCss" type="text/css" href="@test"> 8673 8674 //Font awesome 8675 <link rel="stylesheet" href="@fontAwesomeCssLink" type="text/css"> 8676 8677 //Flag icon 8678 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css" type="text/css"> 8679 8680 //Google fonts 8681 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))); 8682 8683 <link href="https://fonts.googleapis.com/css?family=@family" rel="stylesheet"> 8684 8685 PushPromise(favicon); 8686 PushPromise(fontAwesomeCssLink); 8687 PushPromise("/Files/Templates/Designs/Rapido/css/base/base.min.css"); 8688 PushPromise(autoCssLink); 8689 PushPromise("/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css"); 8690 PushPromise("/Files/Images/placeholder.gif"); 8691 PushPromise("/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css"); 8692 } 8693 8694 @helper RenderMasterManifest() { 8695 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName"))) 8696 { 8697 <link rel="manifest" href="/Files/Templates/Designs/Rapido/manifest.json"> 8698 PushPromise("/Files/Templates/Designs/Rapido/manifest.json"); 8699 } 8700 } 8701 8702 @helper RenderMasterBody() { 8703 List<Block> subBlocks = this.masterPage.GetBlockListById("Body").OrderBy(item => item.SortId).ToList(); 8704 string designLayout = Model.PropertyItem.GetItem("CustomSettings") != null ? Model.PropertyItem.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.PropertyItem.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 8705 if (!String.IsNullOrEmpty(designLayout)) { 8706 designLayout = "class=\"" + designLayout + "\""; 8707 } 8708 8709 <body @designLayout> 8710 @RenderBlockList(subBlocks) 8711 </body> 8712 } 8713 8714 @helper RenderMasterHeader() 8715 { 8716 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterHeader").OrderBy(item => item.SortId).ToList(); 8717 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop"); 8718 string stickyTop = isNavigationStickyMenu ? "top-container--sticky" : ""; 8719 8720 <header class="top-container @stickyTop dw-mod" id="Top"> 8721 @RenderBlockList(subBlocks) 8722 </header> 8723 } 8724 8725 @helper RenderMain() 8726 { 8727 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMain").OrderBy(item => item.SortId).ToList(); 8728 8729 <main class="site dw-mod"> 8730 @RenderBlockList(subBlocks) 8731 </main> 8732 } 8733 8734 @helper RenderPageContent() 8735 { 8736 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop"); 8737 string pagePos = isNavigationStickyMenu ? "js-page-pos" : ""; 8738 8739 <div id="Page" class="page @pagePos"> 8740 <section class="center-container content-container dw-mod" id="content"> 8741 8742 @RenderSnippet("Content") 8743 </section> 8744 </div> 8745 } 8746 8747 @* Hack to support nested helpers *@ 8748 @SnippetStart("Content") 8749 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 8750 8751 8752 @using Dynamicweb.Extensibility 8753 @using Dynamicweb.Core 8754 @using Dynamicweb.Rapido.Blocks.Components 8755 @using Dynamicweb.Rapido.Blocks.Components.Articles 8756 @using Dynamicweb.Rapido.Blocks.Components.General 8757 @using Dynamicweb.Rapido.Blocks 8758 @using Dynamicweb.Content.Items 8759 @using Dynamicweb.Ecommerce.ProductCatalog 8760 8761 @functions { 8762 BlocksPage articlePage = BlocksPage.GetBlockPage("DynamicArticle"); 8763 8764 public string GetParentSettingsItem(string systemName) { 8765 string item = null; 8766 8767 Dynamicweb.Content.Page current = Dynamicweb.Services.Pages.GetPage(Model.ID); 8768 while (current != null && current.Parent != current) { 8769 var temp = current.Item != null ? current.Item[systemName] : ""; 8770 8771 if (temp != null) { 8772 item = temp.ToString(); 8773 8774 if (!String.IsNullOrEmpty(item) && !String.Equals("default", item, StringComparison.OrdinalIgnoreCase)) { 8775 break; 8776 } 8777 } 8778 8779 current = current.Parent; 8780 } 8781 8782 return item; 8783 } 8784 8785 public string GetArticleCategory(int pageId) 8786 { 8787 string categoryName = null; 8788 8789 //Secure that the article is not in the root folder = Actual has a category 8790 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) { 8791 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) { 8792 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType)) 8793 { 8794 categoryName = Dynamicweb.Services.Pages.GetPage(pageId).Parent.GetDisplayName(); 8795 } 8796 } 8797 } 8798 8799 return categoryName; 8800 } 8801 8802 public string GetArticleCategoryColor(int pageId) 8803 { 8804 string categoryColor = ""; 8805 8806 //Secure that the article is not in the root folder = Actual has a category 8807 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) { 8808 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) { 8809 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType)) 8810 { 8811 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"] != null) 8812 { 8813 var service = new ColorSwatchService(); 8814 categoryColor = Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"].ToString(); 8815 8816 if (!categoryColor.Contains("#")) { 8817 categoryColor = service.GetHexColor(Converter.ToInt32(Model.Area.ID), categoryColor); 8818 } 8819 } 8820 } 8821 } 8822 } 8823 8824 return categoryColor; 8825 } 8826 } 8827 8828 @{ 8829 string listPageId = Converter.ToString(GetPageIdByNavigationTag("DynamicListFeed")); 8830 string parentPageId = Dynamicweb.Services.Pages.GetPage(Model.ID).Parent.ID.ToString(); 8831 string topLayout = Model.Item.GetList("TopLayout") != null ? Model.Item.GetList("TopLayout").SelectedValue : "default"; 8832 topLayout = topLayout == "default" && GetParentSettingsItem("ArticleTopLayout") != null ? GetParentSettingsItem("ArticleTopLayout").ToString().ToLower() : topLayout; 8833 string textLayout = Model.Item.GetList("TextLayout") != null ? Model.Item.GetList("TextLayout").SelectedValue : "default"; 8834 textLayout = textLayout == "default" && GetParentSettingsItem("ArticleTextLayout") != null ? GetParentSettingsItem("ArticleTextLayout").ToString().ToLower() : textLayout; 8835 string imageLayout = Model.Item.GetList("ImageLayout") != null ? Model.Item.GetList("ImageLayout").SelectedValue : "default"; 8836 imageLayout = imageLayout == "default" && GetParentSettingsItem("ArticleImageLayout") != null ? GetParentSettingsItem("ArticleImageLayout").ToString().ToLower() : imageLayout; 8837 8838 string imageColumns = imageLayout == "straight" && textLayout != "full" ? "8" : "12"; 8839 string contentColumns = textLayout != "full" ? "8" : "12"; 8840 8841 int externalParagraphId = Model.Item.GetItem("CTAParagraphLink") != null ? Model.Item.GetItem("CTAParagraphLink").ParagraphID : 0; 8842 8843 ArticleHeaderLayout headerLayout; 8844 8845 switch (topLayout) 8846 { 8847 case "default": 8848 headerLayout = ArticleHeaderLayout.Clean; 8849 break; 8850 case "split": 8851 headerLayout = ArticleHeaderLayout.Split; 8852 break; 8853 case "banner": 8854 headerLayout = ArticleHeaderLayout.Banner; 8855 break; 8856 case "overlay": 8857 headerLayout = ArticleHeaderLayout.Overlay; 8858 break; 8859 default: 8860 headerLayout = ArticleHeaderLayout.Clean; 8861 break; 8862 } 8863 8864 8865 Block articleContainer = new Block 8866 { 8867 Id = "ArticleContainer", 8868 SortId = 10, 8869 Design = new Design 8870 { 8871 RenderType = RenderType.Row 8872 }, 8873 BlocksList = new List<Block> { 8874 new Block { 8875 Id = "ArticleBody", 8876 SortId = 30, 8877 Design = new Design { 8878 RenderType = RenderType.Column, 8879 Size = "12", 8880 HidePadding = true 8881 } 8882 } 8883 } 8884 }; 8885 articlePage.Add(articleContainer); 8886 8887 ButtonLayout topBannerButtonLayout = ButtonLayout.Primary; 8888 8889 switch (Model.Item.GetString("ButtonDesign")) { 8890 case "primary": 8891 topBannerButtonLayout = ButtonLayout.Primary; 8892 break; 8893 case "secondary": 8894 topBannerButtonLayout = ButtonLayout.Secondary; 8895 break; 8896 case "teritary": 8897 topBannerButtonLayout = ButtonLayout.Tertiary; 8898 break; 8899 case "link": 8900 topBannerButtonLayout = ButtonLayout.Link; 8901 break; 8902 } 8903 8904 ArticleHeader topBanner = new ArticleHeader 8905 { 8906 Layout = headerLayout, 8907 Image = new Image { Path = Model.Item.GetFile("Image"), ImageDefault = new ImageSettings { Width = 1920, Height = 640 } }, 8908 Heading = Model.Item.GetString("Title"), 8909 Subheading = Model.Item.GetString("Summary"), 8910 TextColor = "#fff", 8911 Author = Model.Item.GetString("Author"), 8912 Date = Model.Item.GetString("Date"), 8913 Category = GetArticleCategory(Model.ID), 8914 CategoryColor = GetArticleCategoryColor(Model.ID), 8915 Link = Model.Item.GetString("Link"), 8916 LinkText = Model.Item.GetString("LinkText"), 8917 ButtonLayout = topBannerButtonLayout, 8918 RatingScore = Model.Item.GetString("Rating") != null ? Converter.ToInt32(Model.Item.GetList("Rating").SelectedValue) : 0, 8919 RatingOutOf = Model.Item.GetString("Rating") != null ? Model.Item.GetList("Rating").Options.Count : 0, 8920 ExternalParagraphId = externalParagraphId 8921 }; 8922 8923 Block articleTop = new Block 8924 { 8925 Id = "ArticleHead", 8926 SortId = 20, 8927 Component = topBanner, 8928 Design = new Design 8929 { 8930 RenderType = RenderType.Column, 8931 Size = "12", 8932 HidePadding = true, 8933 CssClass = "article-head" 8934 } 8935 }; 8936 articlePage.Add("ArticleContainer", articleTop); 8937 8938 8939 Block articleBodyRow = new Block 8940 { 8941 Id = "ArticleBodyRow", 8942 SortId = 10, 8943 SkipRenderBlocksList = true 8944 }; 8945 articlePage.Add("ArticleBody", articleBodyRow); 8946 8947 8948 if (Model.Item.GetString("Paragraphs") != null) 8949 { 8950 int count = 0; 8951 foreach (var paragraph in Model.Item.GetItems("Paragraphs")) 8952 { 8953 if (!paragraph.GetBoolean("RenderAsQuote")) 8954 { 8955 string enableDropCap = Model.Item.GetString("EnableDropCap") != null ? Model.Item.GetList("EnableDropCap").SelectedValue.ToLower() : "default"; 8956 enableDropCap = enableDropCap == "default" && GetParentSettingsItem("EnableDropCap") != null ? GetParentSettingsItem("EnableDropCap").ToString().ToLower() : enableDropCap; 8957 string text = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : ""; 8958 8959 if (!String.IsNullOrEmpty(text) && enableDropCap == "true" && count == 0 && paragraph.GetString("Text").Substring(0, 3) == "<p>") 8960 { 8961 string firstLetter = paragraph.GetString("Text").Substring(3, 1); 8962 text = paragraph.GetString("Text").Remove(3, 1); 8963 text = text.Insert(3, "<span class=\"article__drop-cap\">" + firstLetter + "</span>"); 8964 } 8965 8966 if (paragraph.GetFile("Image") != null) 8967 { 8968 string imageTitle = !string.IsNullOrEmpty(paragraph.GetString("Heading")) ? paragraph.GetString("Heading") : ""; 8969 8970 Block articleParagraphImage = new Block 8971 { 8972 Id = "ArticleParagraph" + count + "Image", 8973 SortId = (count * 10), 8974 Design = new Design 8975 { 8976 RenderType = RenderType.Column, 8977 Size = imageColumns, 8978 CssClass = "u-color-light--bg u-padding--lg" 8979 } 8980 }; 8981 8982 if (imageLayout == "banner") 8983 { 8984 ArticleBanner banner = new ArticleBanner 8985 { 8986 Image = new Image { Path = paragraph.GetFile("Image"), ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, Caption = paragraph.GetString("ImageCaption") }, 8987 Heading = imageTitle, 8988 UseFilters = false 8989 }; 8990 articleParagraphImage.Component = banner; 8991 } 8992 else 8993 { 8994 ArticleImage image = new ArticleImage 8995 { 8996 Image = new Image 8997 { 8998 Path = paragraph.GetFile("Image"), 8999 Title = imageTitle, 9000 ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, 9001 Caption = paragraph.GetString("ImageCaption") 9002 } 9003 }; 9004 articleParagraphImage.Component = image; 9005 } 9006 9007 articlePage.Add("ArticleBodyRow", articleParagraphImage); 9008 } 9009 9010 if (!String.IsNullOrEmpty(paragraph.GetString("VideoURL"))) 9011 { 9012 Block articleParagraphVideo = new Block 9013 { 9014 Id = "ArticleParagraph" + count + "Video", 9015 SortId = (count * 10) + 1, 9016 Component = new ArticleVideo { Url = paragraph.GetString("VideoURL"), AutoPlay = "false" }, 9017 Design = new Design 9018 { 9019 RenderType = RenderType.Column, 9020 Size = imageColumns, 9021 CssClass = "u-color-light--bg u-padding--lg" 9022 } 9023 }; 9024 articlePage.Add("ArticleBodyRow", articleParagraphVideo); 9025 } 9026 9027 if (!String.IsNullOrEmpty(paragraph.GetString("Heading"))) 9028 { 9029 Block articleParagraphHeader = new Block 9030 { 9031 Id = "ArticleParagraph" + count + "Heading", 9032 SortId = (count * 10) + 2, 9033 Component = new ArticleSubHeader { Title = paragraph.GetString("Heading") }, 9034 Design = new Design 9035 { 9036 RenderType = RenderType.Column, 9037 Size = contentColumns, 9038 CssClass = "u-color-light--bg u-padding--lg" 9039 } 9040 }; 9041 articlePage.Add("ArticleBodyRow", articleParagraphHeader); 9042 } 9043 9044 if (!String.IsNullOrEmpty(text)) 9045 { 9046 Block articleParagraphText = new Block 9047 { 9048 Id = "ArticleParagraph" + count + "Text", 9049 SortId = (count * 10) + 3, 9050 Component = new ArticleText { Text = text }, 9051 Design = new Design 9052 { 9053 RenderType = RenderType.Column, 9054 Size = contentColumns, 9055 CssClass = "u-color-light--bg u-padding--lg" 9056 } 9057 }; 9058 9059 articlePage.Add("ArticleBodyRow", articleParagraphText); 9060 } 9061 } 9062 else 9063 { 9064 if (!String.IsNullOrEmpty(paragraph.GetString("Text"))) 9065 { 9066 string quoteText = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : ""; 9067 string quoteAuthor = paragraph.GetString("Heading") != null ? paragraph.GetString("Heading") : ""; 9068 9069 Block articleParagraphQuote = new Block 9070 { 9071 Id = "ArticleParagraph" + count + "Quote", 9072 SortId = (count * 10) + 3, 9073 Component = new ArticleQuote { Image = new Image { Path = paragraph.GetFile("Image") }, Text = quoteText, Author = quoteAuthor }, 9074 Design = new Design 9075 { 9076 RenderType = RenderType.Column, 9077 Size = contentColumns, 9078 CssClass = "u-color-light--bg u-padding--lg" 9079 } 9080 }; 9081 articlePage.Add("ArticleBodyRow", articleParagraphQuote); 9082 } 9083 } 9084 9085 9086 count++; 9087 } 9088 } 9089 Block articleProducts = new Block 9090 { 9091 Id = "ArticleProducts", 9092 SortId = 1000, 9093 Template = renderArticleProducts(), 9094 Design = new Design 9095 { 9096 RenderType = RenderType.Column, 9097 Size = "12", 9098 CssClass = "u-color-light--bg u-padding--lg" 9099 } 9100 }; 9101 articlePage.Add("ArticleBodyRow", articleProducts); 9102 9103 articleBodyRow.Component = new ArticleBodyRow { SubBlocks = articleBodyRow.BlocksList, TopLayout = topLayout, TextLayout = textLayout }; 9104 9105 9106 //Related 9107 string showRelatedArtices = Model.Item.GetString("ShowRelatedArticles") != null ? Model.Item.GetList("ShowRelatedArticles").SelectedValue.ToLower() : "default"; 9108 showRelatedArtices = showRelatedArtices == "default" && GetParentSettingsItem("ShowRelatedArticles") != null ? GetParentSettingsItem("ShowRelatedArticles").ToString().ToLower() : showRelatedArtices; 9109 9110 if (showRelatedArtices == "true") 9111 { 9112 Block articleRelated = new Block 9113 { 9114 Id = "ArticleRelated", 9115 SortId = 30, 9116 Component = new ArticleRelated { Title = Translate("Related articles"), FeedPageId = listPageId, Query = "sourceType=Page&sourcePage=" + parentPageId, PageSize = 4, CurrentPageId = Model.ID.ToString() }, 9117 Design = new Design 9118 { 9119 RenderType = RenderType.Column, 9120 Size = "12" 9121 } 9122 }; 9123 articlePage.Add("ArticleContainer", articleRelated); 9124 } 9125 } 9126 9127 9128 @helper renderArticleProducts(){ 9129 9130 ProductListViewModel productlist = Model.Item.GetValue("ProductsArticle") as ProductListViewModel; 9131 9132 if (productlist != null) 9133 { 9134 <div class="grid"> 9135 @foreach (var product in productlist.Products) 9136 { 9137 var productId = Dynamicweb.Ecommerce.Products.Product.GetProductById(product.Id); 9138 var imageService = new Dynamicweb.Ecommerce.Products.ProductImageService(); 9139 var image = imageService.GetDefaultDetailImagePath(productId); 9140 9141 var productPageId = GetPageIdByNavigationTag("ProductsPage"); 9142 var link = "/Default.aspx?ID=" + productPageId + "&productId=" + product.Id; 9143 9144 // MENNT 9145 double? stockCustom = product.StockLevel; 9146 var stockState = ""; 9147 var productType = productId.Type; 9148 9149 if (productType.ToString() == "Bom") 9150 { 9151 var bomItems = productId?.Items; 9152 List<double> bomStockList = new List<double>(); 9153 9154 if (bomItems != null) 9155 { 9156 foreach (var bomItem in bomItems) 9157 { 9158 var bomProductFromApi = Dynamicweb.Ecommerce.Products.Product.GetProductById(bomItem.BomProductId); 9159 var bomQuantity = bomItem.Quantity; 9160 var bomStock = bomProductFromApi.Stock; 9161 var bomStockCaclculated = bomStock / bomQuantity; 9162 var bomStockCaclculatedAsInt = bomStockCaclculated > 0 ? Convert.ToInt32(Math.Floor(bomStockCaclculated)) : 0; 9163 9164 bomStockList.Add(bomStockCaclculatedAsInt); 9165 } 9166 } 9167 9168 stockCustom = bomStockList.Count > 0 ? bomStockList.Min<double>() : 102; 9169 stockState = stockCustom > 0 ? "stock-icon--in" : "stock-icon--not"; 9170 } 9171 // END 9172 9173 9174 <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"> 9175 <div class="grid__col--auto u-no-padding u-full-height"> 9176 <div class="grid__cell product-list__grid-item__image dw-mod "> 9177 <a href="@link" class="u-block u-position-relative image-hover__wrapper dw-mod"> 9178 <img src="@image" class="grid__cell-img grid__cell-img--centered u-padding b-lazy b-loaded" alt="@product.Name"></img> 9179 </a> 9180 </div> 9181 <div class="grid__cell product-list__grid-item__price-info dw-mod"> 9182 <a href="@link" class="u-color-inherit"> 9183 <h6 class="u-condensed-text u-bold">@product.Name</h6> 9184 </a> 9185 <div class="item-number dw-mod">@product.Number</div> 9186 <div class="price price--product-list dw-mod">@product.Price.PriceWithVatFormatted</div> 9187 <div class="vat-price vat-price--product-list u-margin-top dw-mod">eks. MVA (@product.Price.PriceWithoutVatFormatted)</div> 9188 </div> 9189 <div class="product-list__grid-item__footer dw-mod"> 9190 <div class="buttons-collection buttons-collection--center"> 9191 <input type="number" id="Quantity_@product.Number" name="quantity" value="1" min="1" class="dw-mod" /> 9192 <button 9193 id='' 9194 class="btn--sm btn btn--secondary dw-mod" 9195 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) })" 9196 title="@Translate("Legg til")"><i class="fa fa-shopping-cart"></i></button> 9197 </div> 9198 @if(stockCustom > 0) 9199 { 9200 if (stockCustom > 100) 9201 { 9202 <span class="stock-icon stock-icon--in u-no-margin dw-mod"></span> 9203 <span style="font-size:15px">Lagerbeholdning: 100+ stk.</span> 9204 } 9205 else 9206 { 9207 <span class="stock-icon stock-icon--in u-no-margin dw-mod"></span> 9208 <span style="font-size:15px">Lagerbeholdning: @stockCustom stk.</span> 9209 } 9210 } 9211 else 9212 { 9213 <span class="stock-icon stock-icon--out u-no-margin dw-mod"></span> 9214 <span style="font-size:15px">Lagerbeholdning: @stockCustom stk.</span> 9215 } 9216 </div> 9217 </div> 9218 </div> 9219 9220 } 9221 </div> 9222 } 9223 } 9224 9225 @using System 9226 @using System.Web 9227 @using System.Collections.Generic 9228 @using Dynamicweb.Rapido.Blocks 9229 9230 @{ 9231 BlocksPage dynamicArticleCustomBlocksPage = BlocksPage.GetBlockPage("DynamicArticle"); 9232 9233 } 9234 9235 9236 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 9237 @RenderBlockList(articlePage.BlocksRoot.BlocksList) 9238 @SnippetEnd("Content") 9239 9240 @helper RenderIosTabletFix() { 9241 if (Pageview.Device != Dynamicweb.Frontend.Devices.DeviceType.Tablet && Pageview.Platform != Dynamicweb.Frontend.Devices.PlatformType.Ios) 9242 { 9243 <script> 9244 let isIpadIOS = (/iPad/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream; 9245 if (isIpadIOS) { 9246 var separator = (window.location.href.indexOf("?") === -1) ? "?" : "&"; 9247 window.location.href = window.location.href + separator + "DeviceType=Tablet&PlatformType=Ios"; 9248 } 9249 </script> 9250 } 9251 } 9252 9253 </html> 9254 9255