Error executing template "Designs/Rapido/_parsed/DynamicArticle.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.<RenderMasterMetadata>b__200_0(TextWriter __razor_helper_writer) in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 7973
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 253
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 163
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.<RenderMasterHead>b__199_0(TextWriter __razor_helper_writer) in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 7918
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 253
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 163
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 286
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 163
   at CompiledRazorTemplates.Dynamic.RazorEngine_f207ce3950d648d09f3fd82d61ed25bd.Execute() in C:\inetpub\wwwroot\copy.hf.dk\Solutions\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 7908
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

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