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