Error executing template "Designs/Rapido/_parsed/DynamicArticle.parsed.cshtml"
System.Exception: Image method 'RenderImage' could not be invoked ---> Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
   at CallSite.Target(Closure , CallSite , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass19_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 848
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass18_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 785
   at RazorEngine.Templating.TemplateWriter.ToString()
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 270
   --- End of inner exception stack trace ---
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 272
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 184
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 279
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 184
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 279
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 173
   at CompiledRazorTemplates.Dynamic.RazorEngine_f4d85f3c36b2444fa61b150a75395e32.Execute() in E:\dynamicweb.net\Solutions\Jmgrafisk\marcobrodde.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 8404
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

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