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