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_c9c9a59da24c4582a1d7f2f1c8d8e267.b__192_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 7338
   at CompiledRazorTemplates.Dynamic.RazorEngine_c9c9a59da24c4582a1d7f2f1c8d8e267.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 248
   at CompiledRazorTemplates.Dynamic.RazorEngine_c9c9a59da24c4582a1d7f2f1c8d8e267.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
   at CompiledRazorTemplates.Dynamic.RazorEngine_c9c9a59da24c4582a1d7f2f1c8d8e267.b__191_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 7283
   at CompiledRazorTemplates.Dynamic.RazorEngine_c9c9a59da24c4582a1d7f2f1c8d8e267.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 248
   at CompiledRazorTemplates.Dynamic.RazorEngine_c9c9a59da24c4582a1d7f2f1c8d8e267.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
   at CompiledRazorTemplates.Dynamic.RazorEngine_c9c9a59da24c4582a1d7f2f1c8d8e267.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 279
   at CompiledRazorTemplates.Dynamic.RazorEngine_c9c9a59da24c4582a1d7f2f1c8d8e267.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
   at CompiledRazorTemplates.Dynamic.RazorEngine_c9c9a59da24c4582a1d7f2f1c8d8e267.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 7273
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

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