Error executing template "Designs/Rapido/_parsed/ContentPage.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_b5eeb0a79827495d9235acd69b105428.<RenderMasterBody>b__204_0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\staging.nordenta.dk\Application\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 8557
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_b5eeb0a79827495d9235acd69b105428.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\staging.nordenta.dk\Application\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 254
   at CompiledRazorTemplates.Dynamic.RazorEngine_b5eeb0a79827495d9235acd69b105428.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\staging.nordenta.dk\Application\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 164
   at CompiledRazorTemplates.Dynamic.RazorEngine_b5eeb0a79827495d9235acd69b105428.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\staging.nordenta.dk\Application\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 287
   at CompiledRazorTemplates.Dynamic.RazorEngine_b5eeb0a79827495d9235acd69b105428.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\staging.nordenta.dk\Application\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 164
   at CompiledRazorTemplates.Dynamic.RazorEngine_b5eeb0a79827495d9235acd69b105428.Execute() in E:\dynamicweb.net\Solutions\staging.nordenta.dk\Application\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 8396
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

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