Error executing template "Designs/Rapido/_parsed/Page.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.b__215_0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 8179
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 248
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.b__214_0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 8124
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 248
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 279
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
   at CompiledRazorTemplates.Dynamic.RazorEngine_47b3477b7a724402ad704ea4f60382b8.Execute() in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 8114
   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.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

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